]>
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; | |
1617 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; | |
1618 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; | |
1619 | bm->process_rsclient_queue->spec.del_item_data | |
1620 | = bm->process_main_queue->spec.del_item_data; | |
1621 | bm->process_main_queue->spec.max_retries | |
1622 | = bm->process_main_queue->spec.max_retries = 0; | |
1623 | bm->process_rsclient_queue->spec.hold | |
09dd561e | 1624 | = bm->process_main_queue->spec.hold = 50; |
200df115 | 1625 | } |
1626 | ||
1627 | void | |
fee0f4c6 | 1628 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1629 | { | |
200df115 | 1630 | struct bgp_process_queue *pqnode; |
1631 | ||
1632 | /* already scheduled for processing? */ | |
1633 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1634 | return; | |
1635 | ||
1636 | if ( (bm->process_main_queue == NULL) || | |
1637 | (bm->process_rsclient_queue == NULL) ) | |
1638 | bgp_process_queue_init (); | |
1639 | ||
1640 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, | |
1641 | sizeof (struct bgp_process_queue)); | |
1642 | if (!pqnode) | |
1643 | return; | |
228da428 CC |
1644 | |
1645 | /* all unlocked in bgp_processq_del */ | |
1646 | bgp_table_lock (rn->table); | |
1647 | pqnode->rn = bgp_lock_node (rn); | |
200df115 | 1648 | pqnode->bgp = bgp; |
228da428 | 1649 | bgp_lock (bgp); |
200df115 | 1650 | pqnode->afi = afi; |
1651 | pqnode->safi = safi; | |
1652 | ||
fee0f4c6 | 1653 | switch (rn->table->type) |
1654 | { | |
200df115 | 1655 | case BGP_TABLE_MAIN: |
1656 | work_queue_add (bm->process_main_queue, pqnode); | |
1657 | break; | |
1658 | case BGP_TABLE_RSCLIENT: | |
1659 | work_queue_add (bm->process_rsclient_queue, pqnode); | |
1660 | break; | |
fee0f4c6 | 1661 | } |
200df115 | 1662 | |
1663 | return; | |
fee0f4c6 | 1664 | } |
0a486e5f | 1665 | |
94f2b392 | 1666 | static int |
0a486e5f | 1667 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
1668 | { | |
1669 | struct peer *peer; | |
1670 | ||
1671 | peer = THREAD_ARG (thread); | |
1672 | peer->t_pmax_restart = NULL; | |
1673 | ||
1674 | if (BGP_DEBUG (events, EVENTS)) | |
1675 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", | |
1676 | peer->host); | |
1677 | ||
1678 | peer_clear (peer); | |
1679 | ||
1680 | return 0; | |
1681 | } | |
1682 | ||
718e3744 | 1683 | int |
5228ad27 | 1684 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
1685 | safi_t safi, int always) | |
718e3744 | 1686 | { |
e0701b79 | 1687 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
1688 | return 0; | |
1689 | ||
1690 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 1691 | { |
e0701b79 | 1692 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
1693 | && ! always) | |
1694 | return 0; | |
1695 | ||
1696 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1697 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
1698 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
1699 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 1700 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
1701 | ||
1702 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
1703 | return 0; | |
1704 | ||
1705 | { | |
5228ad27 | 1706 | u_int8_t ndata[7]; |
e0701b79 | 1707 | |
1708 | if (safi == SAFI_MPLS_VPN) | |
1709 | safi = BGP_SAFI_VPNV4; | |
5228ad27 | 1710 | |
1711 | ndata[0] = (afi >> 8); | |
1712 | ndata[1] = afi; | |
1713 | ndata[2] = safi; | |
1714 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
1715 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
1716 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
1717 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 1718 | |
1719 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
1720 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
1721 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
1722 | } | |
0a486e5f | 1723 | |
1724 | /* restart timer start */ | |
1725 | if (peer->pmax_restart[afi][safi]) | |
1726 | { | |
1727 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
1728 | ||
1729 | if (BGP_DEBUG (events, EVENTS)) | |
1730 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", | |
1731 | peer->host, peer->v_pmax_restart); | |
1732 | ||
1733 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
1734 | peer->v_pmax_restart); | |
1735 | } | |
1736 | ||
e0701b79 | 1737 | return 1; |
1738 | } | |
1739 | else | |
1740 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
1741 | ||
1742 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
1743 | { | |
1744 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
1745 | && ! always) | |
1746 | return 0; | |
1747 | ||
1748 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1749 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
1750 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
1751 | peer->pmax[afi][safi]); | |
e0701b79 | 1752 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 1753 | } |
e0701b79 | 1754 | else |
1755 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 1756 | return 0; |
1757 | } | |
1758 | ||
b40d939b | 1759 | /* Unconditionally remove the route from the RIB, without taking |
1760 | * damping into consideration (eg, because the session went down) | |
1761 | */ | |
94f2b392 | 1762 | static void |
718e3744 | 1763 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
1764 | afi_t afi, safi_t safi) | |
1765 | { | |
902212c3 | 1766 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1767 | ||
1768 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
1769 | bgp_info_delete (rn, ri); /* keep historical info */ | |
1770 | ||
b40d939b | 1771 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 1772 | } |
1773 | ||
94f2b392 | 1774 | static void |
718e3744 | 1775 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 1776 | afi_t afi, safi_t safi) |
718e3744 | 1777 | { |
718e3744 | 1778 | int status = BGP_DAMP_NONE; |
1779 | ||
b40d939b | 1780 | /* apply dampening, if result is suppressed, we'll be retaining |
1781 | * the bgp_info in the RIB for historical reference. | |
1782 | */ | |
1783 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
1784 | && peer_sort (peer) == BGP_PEER_EBGP) | |
1785 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) | |
1786 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 1787 | { |
902212c3 | 1788 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1789 | return; | |
1790 | } | |
1791 | ||
1792 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 1793 | } |
1794 | ||
94f2b392 | 1795 | static void |
fee0f4c6 | 1796 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1797 | struct attr *attr, struct peer *peer, struct prefix *p, int type, | |
1798 | int sub_type, struct prefix_rd *prd, u_char *tag) | |
1799 | { | |
1800 | struct bgp_node *rn; | |
1801 | struct bgp *bgp; | |
fb982c25 | 1802 | struct attr new_attr = { 0 }; |
fee0f4c6 | 1803 | struct attr *attr_new; |
1804 | struct attr *attr_new2; | |
1805 | struct bgp_info *ri; | |
1806 | struct bgp_info *new; | |
fd79ac91 | 1807 | const char *reason; |
fee0f4c6 | 1808 | char buf[SU_ADDRSTRLEN]; |
1809 | ||
1810 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ | |
1811 | if (peer == rsclient) | |
1812 | return; | |
1813 | ||
1814 | bgp = peer->bgp; | |
1815 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
1816 | ||
1817 | /* Check previously received route. */ | |
1818 | for (ri = rn->info; ri; ri = ri->next) | |
1819 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
1820 | break; | |
1821 | ||
1822 | /* AS path loop check. */ | |
1823 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) | |
1824 | { | |
1825 | reason = "as-path contains our own AS;"; | |
1826 | goto filtered; | |
1827 | } | |
1828 | ||
1829 | /* Route reflector originator ID check. */ | |
1830 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 1831 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
fee0f4c6 | 1832 | { |
1833 | reason = "originator is us;"; | |
1834 | goto filtered; | |
1835 | } | |
fb982c25 PJ |
1836 | |
1837 | bgp_attr_dup (&new_attr, attr); | |
fee0f4c6 | 1838 | |
1839 | /* Apply export policy. */ | |
1840 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && | |
1841 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1842 | { | |
1843 | reason = "export-policy;"; | |
1844 | goto filtered; | |
1845 | } | |
1846 | ||
1847 | attr_new2 = bgp_attr_intern (&new_attr); | |
fb982c25 | 1848 | |
fee0f4c6 | 1849 | /* Apply import policy. */ |
1850 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1851 | { | |
1852 | bgp_attr_unintern (attr_new2); | |
1853 | ||
1854 | reason = "import-policy;"; | |
1855 | goto filtered; | |
1856 | } | |
1857 | ||
1858 | attr_new = bgp_attr_intern (&new_attr); | |
1859 | bgp_attr_unintern (attr_new2); | |
1860 | ||
1861 | /* IPv4 unicast next hop check. */ | |
1862 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
1863 | { | |
1864 | /* Next hop must not be 0.0.0.0 nor Class E address. */ | |
1865 | if (new_attr.nexthop.s_addr == 0 | |
1866 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
1867 | { | |
1868 | bgp_attr_unintern (attr_new); | |
1869 | ||
1870 | reason = "martian next-hop;"; | |
1871 | goto filtered; | |
1872 | } | |
1873 | } | |
fb982c25 PJ |
1874 | |
1875 | /* new_attr isn't passed to any functions after here */ | |
1876 | bgp_attr_extra_free (&new_attr); | |
1877 | ||
fee0f4c6 | 1878 | /* If the update is implicit withdraw. */ |
1879 | if (ri) | |
1880 | { | |
1881 | ri->uptime = time (NULL); | |
1882 | ||
1883 | /* Same attribute comes in. */ | |
16d2e241 PJ |
1884 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
1885 | && attrhash_cmp (ri->attr, attr_new)) | |
fee0f4c6 | 1886 | { |
1887 | ||
1a392d46 | 1888 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1889 | |
1890 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1891 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1892 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
1893 | peer->host, | |
1894 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1895 | p->prefixlen, rsclient->host); | |
1896 | ||
228da428 CC |
1897 | bgp_unlock_node (rn); |
1898 | bgp_attr_unintern (attr_new); | |
fee0f4c6 | 1899 | |
228da428 | 1900 | return; |
fee0f4c6 | 1901 | } |
1902 | ||
16d2e241 PJ |
1903 | /* Withdraw/Announce before we fully processed the withdraw */ |
1904 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
1905 | bgp_info_restore (rn, ri); | |
1906 | ||
fee0f4c6 | 1907 | /* Received Logging. */ |
1908 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1909 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1910 | peer->host, |
1911 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1912 | p->prefixlen, rsclient->host); | |
1913 | ||
1914 | /* The attribute is changed. */ | |
1a392d46 | 1915 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1916 | |
1917 | /* Update to new attribute. */ | |
1918 | bgp_attr_unintern (ri->attr); | |
1919 | ri->attr = attr_new; | |
1920 | ||
1921 | /* Update MPLS tag. */ | |
1922 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1923 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
fee0f4c6 | 1924 | |
1a392d46 | 1925 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
fee0f4c6 | 1926 | |
1927 | /* Process change. */ | |
1928 | bgp_process (bgp, rn, afi, safi); | |
1929 | bgp_unlock_node (rn); | |
1930 | ||
1931 | return; | |
1932 | } | |
1933 | ||
1934 | /* Received Logging. */ | |
1935 | if (BGP_DEBUG (update, UPDATE_IN)) | |
1936 | { | |
d2c1f16b | 1937 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1938 | peer->host, |
1939 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1940 | p->prefixlen, rsclient->host); | |
1941 | } | |
1942 | ||
1943 | /* Make new BGP info. */ | |
1944 | new = bgp_info_new (); | |
1945 | new->type = type; | |
1946 | new->sub_type = sub_type; | |
1947 | new->peer = peer; | |
1948 | new->attr = attr_new; | |
1949 | new->uptime = time (NULL); | |
1950 | ||
1951 | /* Update MPLS tag. */ | |
1952 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1953 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
fee0f4c6 | 1954 | |
1a392d46 | 1955 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
fee0f4c6 | 1956 | |
1957 | /* Register new BGP information. */ | |
1958 | bgp_info_add (rn, new); | |
200df115 | 1959 | |
1960 | /* route_node_get lock */ | |
1961 | bgp_unlock_node (rn); | |
1962 | ||
fee0f4c6 | 1963 | /* Process change. */ |
1964 | bgp_process (bgp, rn, afi, safi); | |
fb982c25 PJ |
1965 | |
1966 | bgp_attr_extra_free (&new_attr); | |
1967 | ||
fee0f4c6 | 1968 | return; |
1969 | ||
1970 | filtered: | |
1971 | ||
1972 | /* This BGP update is filtered. Log the reason then update BGP entry. */ | |
1973 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1974 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1975 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
1976 | peer->host, | |
1977 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1978 | p->prefixlen, rsclient->host, reason); | |
1979 | ||
1980 | if (ri) | |
b40d939b | 1981 | bgp_rib_remove (rn, ri, peer, afi, safi); |
fee0f4c6 | 1982 | |
1983 | bgp_unlock_node (rn); | |
fb982c25 PJ |
1984 | |
1985 | if (new_attr.extra) | |
1986 | bgp_attr_extra_free (&new_attr); | |
1987 | ||
fee0f4c6 | 1988 | return; |
1989 | } | |
1990 | ||
94f2b392 | 1991 | static void |
fee0f4c6 | 1992 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1993 | struct peer *peer, struct prefix *p, int type, int sub_type, | |
1994 | struct prefix_rd *prd, u_char *tag) | |
228da428 | 1995 | { |
fee0f4c6 | 1996 | struct bgp_node *rn; |
1997 | struct bgp_info *ri; | |
1998 | char buf[SU_ADDRSTRLEN]; | |
1999 | ||
2000 | if (rsclient == peer) | |
228da428 | 2001 | return; |
fee0f4c6 | 2002 | |
2003 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
2004 | ||
2005 | /* Lookup withdrawn route. */ | |
2006 | for (ri = rn->info; ri; ri = ri->next) | |
2007 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2008 | break; | |
2009 | ||
2010 | /* Withdraw specified route from routing table. */ | |
2011 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2012 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
fee0f4c6 | 2013 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2014 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 2015 | "%s Can't find the route %s/%d", peer->host, |
2016 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2017 | p->prefixlen); | |
2018 | ||
2019 | /* Unlock bgp_node_get() lock. */ | |
228da428 CC |
2020 | bgp_unlock_node (rn); |
2021 | } | |
fee0f4c6 | 2022 | |
94f2b392 | 2023 | static int |
fee0f4c6 | 2024 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
718e3744 | 2025 | afi_t afi, safi_t safi, int type, int sub_type, |
2026 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2027 | { | |
2028 | int ret; | |
2029 | int aspath_loop_count = 0; | |
2030 | struct bgp_node *rn; | |
2031 | struct bgp *bgp; | |
fb982c25 | 2032 | struct attr new_attr = { 0 }; |
718e3744 | 2033 | struct attr *attr_new; |
2034 | struct bgp_info *ri; | |
2035 | struct bgp_info *new; | |
fd79ac91 | 2036 | const char *reason; |
718e3744 | 2037 | char buf[SU_ADDRSTRLEN]; |
2038 | ||
2039 | bgp = peer->bgp; | |
fee0f4c6 | 2040 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2041 | |
718e3744 | 2042 | /* When peer's soft reconfiguration enabled. Record input packet in |
2043 | Adj-RIBs-In. */ | |
2044 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2045 | && peer != bgp->peer_self && ! soft_reconfig) | |
2046 | bgp_adj_in_set (rn, peer, attr); | |
2047 | ||
2048 | /* Check previously received route. */ | |
2049 | for (ri = rn->info; ri; ri = ri->next) | |
2050 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2051 | break; | |
2052 | ||
2053 | /* AS path local-as loop check. */ | |
2054 | if (peer->change_local_as) | |
2055 | { | |
2056 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2057 | aspath_loop_count = 1; | |
2058 | ||
2059 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2060 | { | |
2061 | reason = "as-path contains our own AS;"; | |
2062 | goto filtered; | |
2063 | } | |
2064 | } | |
2065 | ||
2066 | /* AS path loop check. */ | |
2067 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2068 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2069 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2070 | > peer->allowas_in[afi][safi])) | |
2071 | { | |
2072 | reason = "as-path contains our own AS;"; | |
2073 | goto filtered; | |
2074 | } | |
2075 | ||
2076 | /* Route reflector originator ID check. */ | |
2077 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2078 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2079 | { |
2080 | reason = "originator is us;"; | |
2081 | goto filtered; | |
2082 | } | |
2083 | ||
2084 | /* Route reflector cluster ID check. */ | |
2085 | if (bgp_cluster_filter (peer, attr)) | |
2086 | { | |
2087 | reason = "reflected from the same cluster;"; | |
2088 | goto filtered; | |
2089 | } | |
2090 | ||
2091 | /* Apply incoming filter. */ | |
2092 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2093 | { | |
2094 | reason = "filter;"; | |
2095 | goto filtered; | |
2096 | } | |
2097 | ||
2098 | /* Apply incoming route-map. */ | |
fb982c25 | 2099 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2100 | |
2101 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
2102 | { | |
2103 | reason = "route-map;"; | |
2104 | goto filtered; | |
2105 | } | |
2106 | ||
2107 | /* IPv4 unicast next hop check. */ | |
2108 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
2109 | { | |
2110 | /* If the peer is EBGP and nexthop is not on connected route, | |
2111 | discard it. */ | |
2112 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 | |
2113 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) | |
6ffd2079 | 2114 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
718e3744 | 2115 | { |
2116 | reason = "non-connected next-hop;"; | |
2117 | goto filtered; | |
2118 | } | |
2119 | ||
2120 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop | |
2121 | must not be my own address. */ | |
2122 | if (bgp_nexthop_self (afi, &new_attr) | |
2123 | || new_attr.nexthop.s_addr == 0 | |
2124 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
2125 | { | |
2126 | reason = "martian next-hop;"; | |
2127 | goto filtered; | |
2128 | } | |
2129 | } | |
2130 | ||
2131 | attr_new = bgp_attr_intern (&new_attr); | |
2132 | ||
2133 | /* If the update is implicit withdraw. */ | |
2134 | if (ri) | |
2135 | { | |
2136 | ri->uptime = time (NULL); | |
2137 | ||
2138 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2139 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2140 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2141 | { |
1a392d46 | 2142 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 2143 | |
2144 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2145 | && peer_sort (peer) == BGP_PEER_EBGP | |
2146 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2147 | { | |
2148 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2149 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2150 | peer->host, |
2151 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2152 | p->prefixlen); | |
2153 | ||
902212c3 | 2154 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2155 | { | |
2156 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2157 | bgp_process (bgp, rn, afi, safi); | |
2158 | } | |
718e3744 | 2159 | } |
16d2e241 | 2160 | else /* Duplicate - odd */ |
718e3744 | 2161 | { |
2162 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2163 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2164 | "%s rcvd %s/%d...duplicate ignored", |
2165 | peer->host, | |
2166 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2167 | p->prefixlen); | |
93406d87 | 2168 | |
2169 | /* graceful restart STALE flag unset. */ | |
2170 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2171 | { | |
1a392d46 | 2172 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2173 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2174 | } |
718e3744 | 2175 | } |
2176 | ||
2177 | bgp_unlock_node (rn); | |
2178 | bgp_attr_unintern (attr_new); | |
fb982c25 PJ |
2179 | bgp_attr_extra_free (&new_attr); |
2180 | ||
718e3744 | 2181 | return 0; |
2182 | } | |
2183 | ||
16d2e241 PJ |
2184 | /* Withdraw/Announce before we fully processed the withdraw */ |
2185 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2186 | { | |
2187 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2188 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", | |
2189 | peer->host, | |
2190 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2191 | p->prefixlen); | |
2192 | bgp_info_restore (rn, ri); | |
2193 | } | |
2194 | ||
718e3744 | 2195 | /* Received Logging. */ |
2196 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2197 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2198 | peer->host, |
2199 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2200 | p->prefixlen); | |
2201 | ||
93406d87 | 2202 | /* graceful restart STALE flag unset. */ |
2203 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2204 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2205 | |
718e3744 | 2206 | /* The attribute is changed. */ |
1a392d46 | 2207 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2208 | |
2209 | /* implicit withdraw, decrement aggregate and pcount here. | |
2210 | * only if update is accepted, they'll increment below. | |
2211 | */ | |
902212c3 | 2212 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2213 | ||
718e3744 | 2214 | /* Update bgp route dampening information. */ |
2215 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2216 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2217 | { | |
2218 | /* This is implicit withdraw so we should update dampening | |
2219 | information. */ | |
2220 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2221 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2222 | } |
2223 | ||
718e3744 | 2224 | /* Update to new attribute. */ |
2225 | bgp_attr_unintern (ri->attr); | |
2226 | ri->attr = attr_new; | |
2227 | ||
2228 | /* Update MPLS tag. */ | |
2229 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2230 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2231 | |
2232 | /* Update bgp route dampening information. */ | |
2233 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2234 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2235 | { | |
2236 | /* Now we do normal update dampening. */ | |
2237 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2238 | if (ret == BGP_DAMP_SUPPRESSED) | |
2239 | { | |
2240 | bgp_unlock_node (rn); | |
fb982c25 | 2241 | bgp_attr_extra_free (&new_attr); |
718e3744 | 2242 | return 0; |
2243 | } | |
2244 | } | |
2245 | ||
2246 | /* Nexthop reachability check. */ | |
2247 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2248 | && safi == SAFI_UNICAST | |
2249 | && (peer_sort (peer) == BGP_PEER_IBGP | |
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; | |
2286 | new->uptime = time (NULL); | |
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 | |
2296 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) | |
6ffd2079 | 2297 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2298 | { |
2299 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) | |
1a392d46 | 2300 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2301 | else |
1a392d46 | 2302 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2303 | } |
2304 | else | |
1a392d46 | 2305 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2306 | |
902212c3 | 2307 | /* Increment prefix */ |
718e3744 | 2308 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2309 | ||
2310 | /* Register new BGP information. */ | |
2311 | bgp_info_add (rn, new); | |
200df115 | 2312 | |
2313 | /* route_node_get lock */ | |
2314 | bgp_unlock_node (rn); | |
2315 | ||
fb982c25 PJ |
2316 | bgp_attr_extra_free (&new_attr); |
2317 | ||
718e3744 | 2318 | /* If maximum prefix count is configured and current prefix |
2319 | count exeed it. */ | |
e0701b79 | 2320 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2321 | return -1; | |
718e3744 | 2322 | |
2323 | /* Process change. */ | |
2324 | bgp_process (bgp, rn, afi, safi); | |
2325 | ||
2326 | return 0; | |
2327 | ||
2328 | /* This BGP update is filtered. Log the reason then update BGP | |
2329 | entry. */ | |
2330 | filtered: | |
2331 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2332 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2333 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
2334 | peer->host, | |
2335 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2336 | p->prefixlen, reason); | |
2337 | ||
2338 | if (ri) | |
b40d939b | 2339 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2340 | |
2341 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2342 | |
2343 | bgp_attr_extra_free (&new_attr); | |
2344 | ||
718e3744 | 2345 | return 0; |
2346 | } | |
2347 | ||
fee0f4c6 | 2348 | int |
2349 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, | |
2350 | afi_t afi, safi_t safi, int type, int sub_type, | |
2351 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2352 | { | |
2353 | struct peer *rsclient; | |
1eb8ef25 | 2354 | struct listnode *node, *nnode; |
fee0f4c6 | 2355 | struct bgp *bgp; |
2356 | int ret; | |
2357 | ||
2358 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, | |
2359 | soft_reconfig); | |
2360 | ||
2361 | bgp = peer->bgp; | |
2362 | ||
2363 | /* Process the update for each RS-client. */ | |
1eb8ef25 | 2364 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2365 | { |
2366 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2367 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, | |
2368 | sub_type, prd, tag); | |
2369 | } | |
2370 | ||
2371 | return ret; | |
2372 | } | |
2373 | ||
718e3744 | 2374 | int |
2375 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, | |
94f2b392 | 2376 | afi_t afi, safi_t safi, int type, int sub_type, |
2377 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2378 | { |
2379 | struct bgp *bgp; | |
2380 | char buf[SU_ADDRSTRLEN]; | |
2381 | struct bgp_node *rn; | |
2382 | struct bgp_info *ri; | |
fee0f4c6 | 2383 | struct peer *rsclient; |
1eb8ef25 | 2384 | struct listnode *node, *nnode; |
718e3744 | 2385 | |
2386 | bgp = peer->bgp; | |
2387 | ||
fee0f4c6 | 2388 | /* Process the withdraw for each RS-client. */ |
1eb8ef25 | 2389 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2390 | { |
2391 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2392 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); | |
2393 | } | |
2394 | ||
718e3744 | 2395 | /* Logging. */ |
2396 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2397 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
718e3744 | 2398 | peer->host, |
2399 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2400 | p->prefixlen); | |
2401 | ||
2402 | /* Lookup node. */ | |
fee0f4c6 | 2403 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2404 | |
2405 | /* If peer is soft reconfiguration enabled. Record input packet for | |
2406 | further calculation. */ | |
2407 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2408 | && peer != bgp->peer_self) | |
2409 | bgp_adj_in_unset (rn, peer); | |
2410 | ||
2411 | /* Lookup withdrawn route. */ | |
2412 | for (ri = rn->info; ri; ri = ri->next) | |
2413 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2414 | break; | |
2415 | ||
2416 | /* Withdraw specified route from routing table. */ | |
2417 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2418 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
718e3744 | 2419 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2420 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2421 | "%s Can't find the route %s/%d", peer->host, |
2422 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2423 | p->prefixlen); | |
2424 | ||
2425 | /* Unlock bgp_node_get() lock. */ | |
2426 | bgp_unlock_node (rn); | |
2427 | ||
2428 | return 0; | |
2429 | } | |
2430 | \f | |
2431 | void | |
2432 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2433 | { | |
2434 | struct bgp *bgp; | |
228da428 | 2435 | struct attr attr = { 0 }; |
fb982c25 | 2436 | struct aspath *aspath = { 0 }; |
718e3744 | 2437 | struct prefix p; |
2438 | struct bgp_info binfo; | |
2439 | struct peer *from; | |
2440 | int ret = RMAP_DENYMATCH; | |
fb982c25 | 2441 | |
b2497024 | 2442 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
fb982c25 PJ |
2443 | return; |
2444 | ||
718e3744 | 2445 | bgp = peer->bgp; |
2446 | from = bgp->peer_self; | |
fb982c25 | 2447 | |
718e3744 | 2448 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
2449 | aspath = attr.aspath; | |
2450 | attr.local_pref = bgp->default_local_pref; | |
2451 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
2452 | ||
2453 | if (afi == AFI_IP) | |
2454 | str2prefix ("0.0.0.0/0", &p); | |
2455 | #ifdef HAVE_IPV6 | |
2456 | else if (afi == AFI_IP6) | |
2457 | { | |
fb982c25 PJ |
2458 | struct attr_extra *ae; |
2459 | attr.extra = NULL; | |
2460 | ||
2461 | ae = bgp_attr_extra_get (&attr); | |
2462 | attr.extra = ae; | |
2463 | ||
718e3744 | 2464 | str2prefix ("::/0", &p); |
2465 | ||
2466 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 2467 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 2468 | IPV6_MAX_BYTELEN); |
fb982c25 | 2469 | ae->mp_nexthop_len = 16; |
718e3744 | 2470 | |
2471 | /* If the peer is on shared nextwork and we have link-local | |
2472 | nexthop set it. */ | |
2473 | if (peer->shared_network | |
2474 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
2475 | { | |
fb982c25 | 2476 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 2477 | IPV6_MAX_BYTELEN); |
fb982c25 | 2478 | ae->mp_nexthop_len = 32; |
718e3744 | 2479 | } |
2480 | } | |
2481 | #endif /* HAVE_IPV6 */ | |
718e3744 | 2482 | |
2483 | if (peer->default_rmap[afi][safi].name) | |
2484 | { | |
2485 | binfo.peer = bgp->peer_self; | |
2486 | binfo.attr = &attr; | |
2487 | ||
fee0f4c6 | 2488 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
2489 | ||
718e3744 | 2490 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
2491 | RMAP_BGP, &binfo); | |
2492 | ||
fee0f4c6 | 2493 | bgp->peer_self->rmap_type = 0; |
2494 | ||
718e3744 | 2495 | if (ret == RMAP_DENYMATCH) |
2496 | { | |
2497 | bgp_attr_flush (&attr); | |
2498 | withdraw = 1; | |
2499 | } | |
2500 | } | |
2501 | ||
2502 | if (withdraw) | |
2503 | { | |
2504 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
2505 | bgp_default_withdraw_send (peer, afi, safi); | |
2506 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2507 | } | |
2508 | else | |
2509 | { | |
2510 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2511 | bgp_default_update_send (peer, &attr, afi, safi, from); | |
2512 | } | |
fb982c25 PJ |
2513 | |
2514 | bgp_attr_extra_free (&attr); | |
718e3744 | 2515 | aspath_unintern (aspath); |
2516 | } | |
2517 | \f | |
2518 | static void | |
2519 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, | |
fee0f4c6 | 2520 | struct bgp_table *table, int rsclient) |
718e3744 | 2521 | { |
2522 | struct bgp_node *rn; | |
2523 | struct bgp_info *ri; | |
228da428 | 2524 | struct attr attr = { 0 }; |
fb982c25 | 2525 | |
718e3744 | 2526 | if (! table) |
fee0f4c6 | 2527 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
718e3744 | 2528 | |
2529 | if (safi != SAFI_MPLS_VPN | |
2530 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
2531 | bgp_default_originate (peer, afi, safi, 0); | |
2532 | ||
2533 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) | |
2534 | for (ri = rn->info; ri; ri = ri->next) | |
2535 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) | |
2536 | { | |
fee0f4c6 | 2537 | if ( (rsclient) ? |
2538 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) | |
2539 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) | |
718e3744 | 2540 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
2541 | else | |
2542 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); | |
fb982c25 PJ |
2543 | |
2544 | bgp_attr_extra_free (&attr); | |
718e3744 | 2545 | } |
2546 | } | |
2547 | ||
2548 | void | |
2549 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2550 | { | |
2551 | struct bgp_node *rn; | |
2552 | struct bgp_table *table; | |
2553 | ||
2554 | if (peer->status != Established) | |
2555 | return; | |
2556 | ||
2557 | if (! peer->afc_nego[afi][safi]) | |
2558 | return; | |
2559 | ||
2560 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ | |
2561 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
2562 | return; | |
2563 | ||
2564 | if (safi != SAFI_MPLS_VPN) | |
fee0f4c6 | 2565 | bgp_announce_table (peer, afi, safi, NULL, 0); |
718e3744 | 2566 | else |
2567 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2568 | rn = bgp_route_next(rn)) | |
2569 | if ((table = (rn->info)) != NULL) | |
fee0f4c6 | 2570 | bgp_announce_table (peer, afi, safi, table, 0); |
2571 | ||
2572 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2573 | bgp_announce_table (peer, afi, safi, NULL, 1); | |
718e3744 | 2574 | } |
2575 | ||
2576 | void | |
2577 | bgp_announce_route_all (struct peer *peer) | |
2578 | { | |
2579 | afi_t afi; | |
2580 | safi_t safi; | |
2581 | ||
2582 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2583 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2584 | bgp_announce_route (peer, afi, safi); | |
2585 | } | |
2586 | \f | |
2587 | static void | |
fee0f4c6 | 2588 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
2589 | safi_t safi, struct bgp_table *table) | |
2590 | { | |
2591 | struct bgp_node *rn; | |
2592 | struct bgp_adj_in *ain; | |
2593 | ||
2594 | if (! table) | |
2595 | table = rsclient->bgp->rib[afi][safi]; | |
2596 | ||
2597 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2598 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2599 | { | |
2600 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, | |
2601 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
2602 | } | |
2603 | } | |
2604 | ||
2605 | void | |
2606 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
2607 | { | |
2608 | struct bgp_table *table; | |
2609 | struct bgp_node *rn; | |
2610 | ||
2611 | if (safi != SAFI_MPLS_VPN) | |
2612 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); | |
2613 | ||
2614 | else | |
2615 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; | |
2616 | rn = bgp_route_next (rn)) | |
2617 | if ((table = rn->info) != NULL) | |
2618 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); | |
2619 | } | |
2620 | \f | |
2621 | static void | |
718e3744 | 2622 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
2623 | struct bgp_table *table) | |
2624 | { | |
2625 | int ret; | |
2626 | struct bgp_node *rn; | |
2627 | struct bgp_adj_in *ain; | |
2628 | ||
2629 | if (! table) | |
2630 | table = peer->bgp->rib[afi][safi]; | |
2631 | ||
2632 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2633 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2634 | { | |
2635 | if (ain->peer == peer) | |
2636 | { | |
2637 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, | |
2638 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, | |
2639 | NULL, NULL, 1); | |
2640 | if (ret < 0) | |
2641 | { | |
2642 | bgp_unlock_node (rn); | |
2643 | return; | |
2644 | } | |
2645 | continue; | |
2646 | } | |
2647 | } | |
2648 | } | |
2649 | ||
2650 | void | |
2651 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2652 | { | |
2653 | struct bgp_node *rn; | |
2654 | struct bgp_table *table; | |
2655 | ||
2656 | if (peer->status != Established) | |
2657 | return; | |
2658 | ||
2659 | if (safi != SAFI_MPLS_VPN) | |
2660 | bgp_soft_reconfig_table (peer, afi, safi, NULL); | |
2661 | else | |
2662 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2663 | rn = bgp_route_next (rn)) | |
2664 | if ((table = rn->info) != NULL) | |
2665 | bgp_soft_reconfig_table (peer, afi, safi, table); | |
2666 | } | |
2667 | \f | |
228da428 CC |
2668 | |
2669 | struct bgp_clear_node_queue | |
2670 | { | |
2671 | struct bgp_node *rn; | |
2672 | enum bgp_clear_route_type purpose; | |
2673 | }; | |
2674 | ||
200df115 | 2675 | static wq_item_status |
0fb58d5d | 2676 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2677 | { |
228da428 CC |
2678 | struct bgp_clear_node_queue *cnq = data; |
2679 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2680 | struct peer *peer = wq->spec.data; |
718e3744 | 2681 | struct bgp_info *ri; |
64e580a7 PJ |
2682 | afi_t afi = rn->table->afi; |
2683 | safi_t safi = rn->table->safi; | |
200df115 | 2684 | |
64e580a7 | 2685 | assert (rn && peer); |
200df115 | 2686 | |
64e580a7 | 2687 | for (ri = rn->info; ri; ri = ri->next) |
228da428 | 2688 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
200df115 | 2689 | { |
2690 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2691 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2692 | && peer->nsf[afi][safi] | |
200df115 | 2693 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2694 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2695 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2696 | else |
64e580a7 | 2697 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2698 | break; |
2699 | } | |
200df115 | 2700 | return WQ_SUCCESS; |
2701 | } | |
2702 | ||
2703 | static void | |
0fb58d5d | 2704 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2705 | { |
228da428 CC |
2706 | struct bgp_clear_node_queue *cnq = data; |
2707 | struct bgp_node *rn = cnq->rn; | |
2708 | struct bgp_table *table = rn->table; | |
64e580a7 PJ |
2709 | |
2710 | bgp_unlock_node (rn); | |
228da428 CC |
2711 | bgp_table_unlock (table); |
2712 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2713 | } |
2714 | ||
2715 | static void | |
94f2b392 | 2716 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2717 | { |
64e580a7 PJ |
2718 | struct peer *peer = wq->spec.data; |
2719 | ||
3e0c78ef | 2720 | /* Tickle FSM to start moving again */ |
ca058a30 | 2721 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2722 | |
2723 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2724 | } |
2725 | ||
2726 | static void | |
64e580a7 | 2727 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2728 | { |
64e580a7 PJ |
2729 | #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */ |
2730 | char wname[CLEAR_QUEUE_NAME_LEN]; | |
2731 | ||
2732 | snprintf (wname, CLEAR_QUEUE_NAME_LEN, "clear %s", peer->host); | |
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; | |
3339 | ri->uptime = time (NULL); | |
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; | |
3357 | new->uptime = time (NULL); | |
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; | |
3465 | ri->uptime = time (NULL); | |
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; | |
3484 | new->uptime = time (NULL); | |
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 |
718e3744 | 3520 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
3521 | u_char safi, struct prefix_rd *prd, u_char *tag) | |
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); | |
3535 | new->uptime = time (NULL); | |
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 |
718e3744 | 3601 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
3602 | u_char safi, struct prefix_rd *prd, u_char *tag) | |
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, |
41367172 PJ |
3655 | u_int16_t afi, u_char safi, const char *rmap, int backdoor, |
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, |
718e3744 | 3800 | u_int16_t afi, u_char safi) |
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); | |
4731 | new->uptime = time (NULL); | |
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); | |
4902 | new->uptime = time (NULL); | |
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; | |
5516 | bi->uptime = time (NULL); | |
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; | |
5534 | new->uptime = time (NULL); | |
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 *); | |
5981 | ||
5982 | attr = binfo->attr; | |
5983 | ||
5984 | if (attr) | |
5985 | { | |
5986 | /* Line1 display AS-path, Aggregator */ | |
5987 | if (attr->aspath) | |
5988 | { | |
5989 | vty_out (vty, " "); | |
fe69a505 | 5990 | if (aspath_count_hops (attr->aspath) == 0) |
718e3744 | 5991 | vty_out (vty, "Local"); |
5992 | else | |
841f7a57 | 5993 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
718e3744 | 5994 | } |
5995 | ||
b40d939b | 5996 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
5997 | vty_out (vty, ", (removed)"); | |
93406d87 | 5998 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
5999 | vty_out (vty, ", (stale)"); | |
6000 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) | |
aea339f7 | 6001 | vty_out (vty, ", (aggregated by %u %s)", |
fb982c25 PJ |
6002 | attr->extra->aggregator_as, |
6003 | inet_ntoa (attr->extra->aggregator_addr)); | |
93406d87 | 6004 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
6005 | vty_out (vty, ", (Received from a RR-client)"); | |
6006 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6007 | vty_out (vty, ", (Received from a RS-client)"); | |
6008 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
6009 | vty_out (vty, ", (history entry)"); | |
6010 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
6011 | vty_out (vty, ", (suppressed due to dampening)"); | |
718e3744 | 6012 | vty_out (vty, "%s", VTY_NEWLINE); |
6013 | ||
6014 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
6015 | if (p->family == AF_INET) | |
6016 | { | |
6017 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? | |
fb982c25 | 6018 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
718e3744 | 6019 | inet_ntoa (attr->nexthop)); |
6020 | } | |
6021 | #ifdef HAVE_IPV6 | |
6022 | else | |
6023 | { | |
fb982c25 | 6024 | assert (attr->extra); |
718e3744 | 6025 | vty_out (vty, " %s", |
fb982c25 | 6026 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
718e3744 | 6027 | buf, INET6_ADDRSTRLEN)); |
6028 | } | |
6029 | #endif /* HAVE_IPV6 */ | |
6030 | ||
6031 | if (binfo->peer == bgp->peer_self) | |
6032 | { | |
6033 | vty_out (vty, " from %s ", | |
6034 | p->family == AF_INET ? "0.0.0.0" : "::"); | |
6035 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); | |
6036 | } | |
6037 | else | |
6038 | { | |
6039 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
6040 | vty_out (vty, " (inaccessible)"); | |
fb982c25 PJ |
6041 | else if (binfo->extra && binfo->extra->igpmetric) |
6042 | vty_out (vty, " (metric %d)", binfo->extra->igpmetric); | |
eb821189 | 6043 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
718e3744 | 6044 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 | 6045 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
718e3744 | 6046 | else |
6047 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
6048 | } | |
6049 | vty_out (vty, "%s", VTY_NEWLINE); | |
6050 | ||
6051 | #ifdef HAVE_IPV6 | |
6052 | /* display nexthop local */ | |
fb982c25 | 6053 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
718e3744 | 6054 | { |
6055 | vty_out (vty, " (%s)%s", | |
fb982c25 | 6056 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
718e3744 | 6057 | buf, INET6_ADDRSTRLEN), |
6058 | VTY_NEWLINE); | |
6059 | } | |
6060 | #endif /* HAVE_IPV6 */ | |
6061 | ||
6062 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ | |
6063 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); | |
6064 | ||
6065 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
6066 | vty_out (vty, ", metric %d", attr->med); | |
6067 | ||
6068 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
6069 | vty_out (vty, ", localpref %d", attr->local_pref); | |
6070 | else | |
6071 | vty_out (vty, ", localpref %d", bgp->default_local_pref); | |
6072 | ||
fb982c25 PJ |
6073 | if (attr->extra && attr->extra->weight != 0) |
6074 | vty_out (vty, ", weight %d", attr->extra->weight); | |
718e3744 | 6075 | |
6076 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
6077 | vty_out (vty, ", valid"); | |
6078 | ||
6079 | if (binfo->peer != bgp->peer_self) | |
6080 | { | |
6081 | if (binfo->peer->as == binfo->peer->local_as) | |
6082 | vty_out (vty, ", internal"); | |
6083 | else | |
6084 | vty_out (vty, ", %s", | |
6085 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); | |
6086 | } | |
6087 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
6088 | vty_out (vty, ", aggregated, local"); | |
6089 | else if (binfo->type != ZEBRA_ROUTE_BGP) | |
6090 | vty_out (vty, ", sourced"); | |
6091 | else | |
6092 | vty_out (vty, ", sourced, local"); | |
6093 | ||
6094 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
6095 | vty_out (vty, ", atomic-aggregate"); | |
6096 | ||
6097 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
6098 | vty_out (vty, ", best"); | |
6099 | ||
6100 | vty_out (vty, "%s", VTY_NEWLINE); | |
6101 | ||
6102 | /* Line 4 display Community */ | |
6103 | if (attr->community) | |
6104 | vty_out (vty, " Community: %s%s", attr->community->str, | |
6105 | VTY_NEWLINE); | |
6106 | ||
6107 | /* Line 5 display Extended-community */ | |
6108 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
fb982c25 PJ |
6109 | vty_out (vty, " Extended Community: %s%s", |
6110 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
718e3744 | 6111 | |
6112 | /* Line 6 display Originator, Cluster-id */ | |
6113 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
6114 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
6115 | { | |
fb982c25 | 6116 | assert (attr->extra); |
718e3744 | 6117 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 PJ |
6118 | vty_out (vty, " Originator: %s", |
6119 | inet_ntoa (attr->extra->originator_id)); | |
718e3744 | 6120 | |
6121 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
6122 | { | |
6123 | int i; | |
6124 | vty_out (vty, ", Cluster list: "); | |
fb982c25 PJ |
6125 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
6126 | vty_out (vty, "%s ", | |
6127 | inet_ntoa (attr->extra->cluster->list[i])); | |
718e3744 | 6128 | } |
6129 | vty_out (vty, "%s", VTY_NEWLINE); | |
6130 | } | |
41367172 PJ |
6131 | |
6132 | /* 7: AS Pathlimit */ | |
6133 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AS_PATHLIMIT)) | |
6134 | { | |
6135 | ||
6136 | vty_out (vty, " AS-Pathlimit: %u", | |
6137 | attr->pathlimit.ttl); | |
6138 | if (attr->pathlimit.as) | |
6139 | vty_out (vty, " (%u)", attr->pathlimit.as); | |
6140 | vty_out (vty, "%s", VTY_NEWLINE); | |
6141 | } | |
6142 | ||
fb982c25 | 6143 | if (binfo->extra && binfo->extra->damp_info) |
718e3744 | 6144 | bgp_damp_info_vty (vty, binfo); |
6145 | ||
6146 | /* Line 7 display Uptime */ | |
6147 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); | |
6148 | } | |
6149 | vty_out (vty, "%s", VTY_NEWLINE); | |
6150 | } | |
6151 | \f | |
b40d939b | 6152 | #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 | 6153 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
718e3744 | 6154 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
6155 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" | |
6156 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
6157 | ||
6158 | enum bgp_show_type | |
6159 | { | |
6160 | bgp_show_type_normal, | |
6161 | bgp_show_type_regexp, | |
6162 | bgp_show_type_prefix_list, | |
6163 | bgp_show_type_filter_list, | |
6164 | bgp_show_type_route_map, | |
6165 | bgp_show_type_neighbor, | |
6166 | bgp_show_type_cidr_only, | |
6167 | bgp_show_type_prefix_longer, | |
6168 | bgp_show_type_community_all, | |
6169 | bgp_show_type_community, | |
6170 | bgp_show_type_community_exact, | |
6171 | bgp_show_type_community_list, | |
6172 | bgp_show_type_community_list_exact, | |
6173 | bgp_show_type_flap_statistics, | |
6174 | bgp_show_type_flap_address, | |
6175 | bgp_show_type_flap_prefix, | |
6176 | bgp_show_type_flap_cidr_only, | |
6177 | bgp_show_type_flap_regexp, | |
6178 | bgp_show_type_flap_filter_list, | |
6179 | bgp_show_type_flap_prefix_list, | |
6180 | bgp_show_type_flap_prefix_longer, | |
6181 | bgp_show_type_flap_route_map, | |
6182 | bgp_show_type_flap_neighbor, | |
6183 | bgp_show_type_dampend_paths, | |
6184 | bgp_show_type_damp_neighbor | |
6185 | }; | |
6186 | ||
5a646650 | 6187 | static int |
fee0f4c6 | 6188 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
5a646650 | 6189 | enum bgp_show_type type, void *output_arg) |
718e3744 | 6190 | { |
718e3744 | 6191 | struct bgp_info *ri; |
6192 | struct bgp_node *rn; | |
718e3744 | 6193 | int header = 1; |
718e3744 | 6194 | int display; |
5a646650 | 6195 | unsigned long output_count; |
718e3744 | 6196 | |
6197 | /* This is first entry point, so reset total line. */ | |
5a646650 | 6198 | output_count = 0; |
718e3744 | 6199 | |
718e3744 | 6200 | /* Start processing of routes. */ |
6201 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
6202 | if (rn->info != NULL) | |
6203 | { | |
6204 | display = 0; | |
6205 | ||
6206 | for (ri = rn->info; ri; ri = ri->next) | |
6207 | { | |
5a646650 | 6208 | if (type == bgp_show_type_flap_statistics |
718e3744 | 6209 | || type == bgp_show_type_flap_address |
6210 | || type == bgp_show_type_flap_prefix | |
6211 | || type == bgp_show_type_flap_cidr_only | |
6212 | || type == bgp_show_type_flap_regexp | |
6213 | || type == bgp_show_type_flap_filter_list | |
6214 | || type == bgp_show_type_flap_prefix_list | |
6215 | || type == bgp_show_type_flap_prefix_longer | |
6216 | || type == bgp_show_type_flap_route_map | |
6217 | || type == bgp_show_type_flap_neighbor | |
6218 | || type == bgp_show_type_dampend_paths | |
6219 | || type == bgp_show_type_damp_neighbor) | |
6220 | { | |
fb982c25 | 6221 | if (!(ri->extra && ri->extra->damp_info)) |
718e3744 | 6222 | continue; |
6223 | } | |
6224 | if (type == bgp_show_type_regexp | |
6225 | || type == bgp_show_type_flap_regexp) | |
6226 | { | |
5a646650 | 6227 | regex_t *regex = output_arg; |
718e3744 | 6228 | |
6229 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) | |
6230 | continue; | |
6231 | } | |
6232 | if (type == bgp_show_type_prefix_list | |
6233 | || type == bgp_show_type_flap_prefix_list) | |
6234 | { | |
5a646650 | 6235 | struct prefix_list *plist = output_arg; |
718e3744 | 6236 | |
6237 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) | |
6238 | continue; | |
6239 | } | |
6240 | if (type == bgp_show_type_filter_list | |
6241 | || type == bgp_show_type_flap_filter_list) | |
6242 | { | |
5a646650 | 6243 | struct as_list *as_list = output_arg; |
718e3744 | 6244 | |
6245 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) | |
6246 | continue; | |
6247 | } | |
6248 | if (type == bgp_show_type_route_map | |
6249 | || type == bgp_show_type_flap_route_map) | |
6250 | { | |
5a646650 | 6251 | struct route_map *rmap = output_arg; |
718e3744 | 6252 | struct bgp_info binfo; |
9eda90ce | 6253 | struct attr dummy_attr = { 0 }; |
718e3744 | 6254 | int ret; |
6255 | ||
fb982c25 | 6256 | bgp_attr_dup (&dummy_attr, ri->attr); |
718e3744 | 6257 | binfo.peer = ri->peer; |
6258 | binfo.attr = &dummy_attr; | |
6259 | ||
6260 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); | |
fb982c25 PJ |
6261 | |
6262 | bgp_attr_extra_free (&dummy_attr); | |
6263 | ||
718e3744 | 6264 | if (ret == RMAP_DENYMATCH) |
6265 | continue; | |
6266 | } | |
6267 | if (type == bgp_show_type_neighbor | |
6268 | || type == bgp_show_type_flap_neighbor | |
6269 | || type == bgp_show_type_damp_neighbor) | |
6270 | { | |
5a646650 | 6271 | union sockunion *su = output_arg; |
718e3744 | 6272 | |
6273 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) | |
6274 | continue; | |
6275 | } | |
6276 | if (type == bgp_show_type_cidr_only | |
6277 | || type == bgp_show_type_flap_cidr_only) | |
6278 | { | |
6279 | u_int32_t destination; | |
6280 | ||
6281 | destination = ntohl (rn->p.u.prefix4.s_addr); | |
6282 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
6283 | continue; | |
6284 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
6285 | continue; | |
6286 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
6287 | continue; | |
6288 | } | |
6289 | if (type == bgp_show_type_prefix_longer | |
6290 | || type == bgp_show_type_flap_prefix_longer) | |
6291 | { | |
5a646650 | 6292 | struct prefix *p = output_arg; |
718e3744 | 6293 | |
6294 | if (! prefix_match (p, &rn->p)) | |
6295 | continue; | |
6296 | } | |
6297 | if (type == bgp_show_type_community_all) | |
6298 | { | |
6299 | if (! ri->attr->community) | |
6300 | continue; | |
6301 | } | |
6302 | if (type == bgp_show_type_community) | |
6303 | { | |
5a646650 | 6304 | struct community *com = output_arg; |
718e3744 | 6305 | |
6306 | if (! ri->attr->community || | |
6307 | ! community_match (ri->attr->community, com)) | |
6308 | continue; | |
6309 | } | |
6310 | if (type == bgp_show_type_community_exact) | |
6311 | { | |
5a646650 | 6312 | struct community *com = output_arg; |
718e3744 | 6313 | |
6314 | if (! ri->attr->community || | |
6315 | ! community_cmp (ri->attr->community, com)) | |
6316 | continue; | |
6317 | } | |
6318 | if (type == bgp_show_type_community_list) | |
6319 | { | |
5a646650 | 6320 | struct community_list *list = output_arg; |
718e3744 | 6321 | |
6322 | if (! community_list_match (ri->attr->community, list)) | |
6323 | continue; | |
6324 | } | |
6325 | if (type == bgp_show_type_community_list_exact) | |
6326 | { | |
5a646650 | 6327 | struct community_list *list = output_arg; |
718e3744 | 6328 | |
6329 | if (! community_list_exact_match (ri->attr->community, list)) | |
6330 | continue; | |
6331 | } | |
6332 | if (type == bgp_show_type_flap_address | |
6333 | || type == bgp_show_type_flap_prefix) | |
6334 | { | |
5a646650 | 6335 | struct prefix *p = output_arg; |
718e3744 | 6336 | |
6337 | if (! prefix_match (&rn->p, p)) | |
6338 | continue; | |
6339 | ||
6340 | if (type == bgp_show_type_flap_prefix) | |
6341 | if (p->prefixlen != rn->p.prefixlen) | |
6342 | continue; | |
6343 | } | |
6344 | if (type == bgp_show_type_dampend_paths | |
6345 | || type == bgp_show_type_damp_neighbor) | |
6346 | { | |
6347 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
6348 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
6349 | continue; | |
6350 | } | |
6351 | ||
6352 | if (header) | |
6353 | { | |
93406d87 | 6354 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
6355 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
6356 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 6357 | if (type == bgp_show_type_dampend_paths |
6358 | || type == bgp_show_type_damp_neighbor) | |
6359 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
6360 | else if (type == bgp_show_type_flap_statistics | |
6361 | || type == bgp_show_type_flap_address | |
6362 | || type == bgp_show_type_flap_prefix | |
6363 | || type == bgp_show_type_flap_cidr_only | |
6364 | || type == bgp_show_type_flap_regexp | |
6365 | || type == bgp_show_type_flap_filter_list | |
6366 | || type == bgp_show_type_flap_prefix_list | |
6367 | || type == bgp_show_type_flap_prefix_longer | |
6368 | || type == bgp_show_type_flap_route_map | |
6369 | || type == bgp_show_type_flap_neighbor) | |
6370 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
6371 | else | |
6372 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
718e3744 | 6373 | header = 0; |
6374 | } | |
6375 | ||
6376 | if (type == bgp_show_type_dampend_paths | |
6377 | || type == bgp_show_type_damp_neighbor) | |
5a646650 | 6378 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6379 | else if (type == bgp_show_type_flap_statistics |
6380 | || type == bgp_show_type_flap_address | |
6381 | || type == bgp_show_type_flap_prefix | |
6382 | || type == bgp_show_type_flap_cidr_only | |
6383 | || type == bgp_show_type_flap_regexp | |
6384 | || type == bgp_show_type_flap_filter_list | |
6385 | || type == bgp_show_type_flap_prefix_list | |
6386 | || type == bgp_show_type_flap_prefix_longer | |
6387 | || type == bgp_show_type_flap_route_map | |
6388 | || type == bgp_show_type_flap_neighbor) | |
5a646650 | 6389 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6390 | else |
5a646650 | 6391 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6392 | display++; |
6393 | } | |
6394 | if (display) | |
5a646650 | 6395 | output_count++; |
718e3744 | 6396 | } |
6397 | ||
6398 | /* No route is displayed */ | |
5a646650 | 6399 | if (output_count == 0) |
718e3744 | 6400 | { |
6401 | if (type == bgp_show_type_normal) | |
6402 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); | |
6403 | } | |
6404 | else | |
6405 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
5a646650 | 6406 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
718e3744 | 6407 | |
6408 | return CMD_SUCCESS; | |
6409 | } | |
6410 | ||
5a646650 | 6411 | static int |
fee0f4c6 | 6412 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
5a646650 | 6413 | enum bgp_show_type type, void *output_arg) |
fee0f4c6 | 6414 | { |
6415 | struct bgp_table *table; | |
6416 | ||
6417 | if (bgp == NULL) { | |
6418 | bgp = bgp_get_default (); | |
6419 | } | |
6420 | ||
6421 | if (bgp == NULL) | |
6422 | { | |
6423 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6424 | return CMD_WARNING; | |
6425 | } | |
6426 | ||
6427 | ||
6428 | table = bgp->rib[afi][safi]; | |
6429 | ||
5a646650 | 6430 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
fee0f4c6 | 6431 | } |
6432 | ||
718e3744 | 6433 | /* Header of detailed BGP route information */ |
94f2b392 | 6434 | static void |
718e3744 | 6435 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
6436 | struct bgp_node *rn, | |
6437 | struct prefix_rd *prd, afi_t afi, safi_t safi) | |
6438 | { | |
6439 | struct bgp_info *ri; | |
6440 | struct prefix *p; | |
6441 | struct peer *peer; | |
1eb8ef25 | 6442 | struct listnode *node, *nnode; |
718e3744 | 6443 | char buf1[INET6_ADDRSTRLEN]; |
6444 | char buf2[INET6_ADDRSTRLEN]; | |
6445 | int count = 0; | |
6446 | int best = 0; | |
6447 | int suppress = 0; | |
6448 | int no_export = 0; | |
6449 | int no_advertise = 0; | |
6450 | int local_as = 0; | |
6451 | int first = 0; | |
6452 | ||
6453 | p = &rn->p; | |
6454 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
6455 | (safi == SAFI_MPLS_VPN ? | |
6456 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), | |
6457 | safi == SAFI_MPLS_VPN ? ":" : "", | |
6458 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
6459 | p->prefixlen, VTY_NEWLINE); | |
6460 | ||
6461 | for (ri = rn->info; ri; ri = ri->next) | |
6462 | { | |
6463 | count++; | |
6464 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
6465 | { | |
6466 | best = count; | |
fb982c25 | 6467 | if (ri->extra && ri->extra->suppress) |
718e3744 | 6468 | suppress = 1; |
6469 | if (ri->attr->community != NULL) | |
6470 | { | |
6471 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
6472 | no_advertise = 1; | |
6473 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
6474 | no_export = 1; | |
6475 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
6476 | local_as = 1; | |
6477 | } | |
6478 | } | |
6479 | } | |
6480 | ||
6481 | vty_out (vty, "Paths: (%d available", count); | |
6482 | if (best) | |
6483 | { | |
6484 | vty_out (vty, ", best #%d", best); | |
6485 | if (safi == SAFI_UNICAST) | |
6486 | vty_out (vty, ", table Default-IP-Routing-Table"); | |
6487 | } | |
6488 | else | |
6489 | vty_out (vty, ", no best path"); | |
6490 | if (no_advertise) | |
6491 | vty_out (vty, ", not advertised to any peer"); | |
6492 | else if (no_export) | |
6493 | vty_out (vty, ", not advertised to EBGP peer"); | |
6494 | else if (local_as) | |
6495 | vty_out (vty, ", not advertised outside local AS"); | |
6496 | if (suppress) | |
6497 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
6498 | vty_out (vty, ")%s", VTY_NEWLINE); | |
6499 | ||
6500 | /* advertised peer */ | |
1eb8ef25 | 6501 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6502 | { |
6503 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) | |
6504 | { | |
6505 | if (! first) | |
6506 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); | |
6507 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6508 | first = 1; | |
6509 | } | |
6510 | } | |
6511 | if (! first) | |
6512 | vty_out (vty, " Not advertised to any peer"); | |
6513 | vty_out (vty, "%s", VTY_NEWLINE); | |
6514 | } | |
6515 | ||
6516 | /* Display specified route of BGP table. */ | |
94f2b392 | 6517 | static int |
fee0f4c6 | 6518 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 6519 | struct bgp_table *rib, const char *ip_str, |
6520 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
6521 | int prefix_check) | |
718e3744 | 6522 | { |
6523 | int ret; | |
6524 | int header; | |
6525 | int display = 0; | |
6526 | struct prefix match; | |
6527 | struct bgp_node *rn; | |
6528 | struct bgp_node *rm; | |
6529 | struct bgp_info *ri; | |
718e3744 | 6530 | struct bgp_table *table; |
6531 | ||
718e3744 | 6532 | /* Check IP address argument. */ |
6533 | ret = str2prefix (ip_str, &match); | |
6534 | if (! ret) | |
6535 | { | |
6536 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
6537 | return CMD_WARNING; | |
6538 | } | |
6539 | ||
6540 | match.family = afi2family (afi); | |
6541 | ||
6542 | if (safi == SAFI_MPLS_VPN) | |
6543 | { | |
fee0f4c6 | 6544 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 6545 | { |
6546 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6547 | continue; | |
6548 | ||
6549 | if ((table = rn->info) != NULL) | |
6550 | { | |
6551 | header = 1; | |
6552 | ||
6553 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6554 | { | |
6555 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6556 | continue; | |
6557 | ||
6558 | for (ri = rm->info; ri; ri = ri->next) | |
6559 | { | |
6560 | if (header) | |
6561 | { | |
6562 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
6563 | AFI_IP, SAFI_MPLS_VPN); | |
6564 | ||
6565 | header = 0; | |
6566 | } | |
6567 | display++; | |
6568 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); | |
6569 | } | |
6570 | } | |
6571 | } | |
6572 | } | |
6573 | } | |
6574 | else | |
6575 | { | |
6576 | header = 1; | |
6577 | ||
fee0f4c6 | 6578 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 6579 | { |
6580 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
6581 | { | |
6582 | for (ri = rn->info; ri; ri = ri->next) | |
6583 | { | |
6584 | if (header) | |
6585 | { | |
6586 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); | |
6587 | header = 0; | |
6588 | } | |
6589 | display++; | |
6590 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); | |
6591 | } | |
6592 | } | |
6593 | } | |
6594 | } | |
6595 | ||
6596 | if (! display) | |
6597 | { | |
6598 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
6599 | return CMD_WARNING; | |
6600 | } | |
6601 | ||
6602 | return CMD_SUCCESS; | |
6603 | } | |
6604 | ||
fee0f4c6 | 6605 | /* Display specified route of Main RIB */ |
94f2b392 | 6606 | static int |
fd79ac91 | 6607 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 6608 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
6609 | int prefix_check) | |
6610 | { | |
6611 | struct bgp *bgp; | |
6612 | ||
6613 | /* BGP structure lookup. */ | |
6614 | if (view_name) | |
6615 | { | |
6616 | bgp = bgp_lookup_by_name (view_name); | |
6617 | if (bgp == NULL) | |
6618 | { | |
6619 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
6620 | return CMD_WARNING; | |
6621 | } | |
6622 | } | |
6623 | else | |
6624 | { | |
6625 | bgp = bgp_get_default (); | |
6626 | if (bgp == NULL) | |
6627 | { | |
6628 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6629 | return CMD_WARNING; | |
6630 | } | |
6631 | } | |
6632 | ||
6633 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
6634 | afi, safi, prd, prefix_check); | |
6635 | } | |
6636 | ||
718e3744 | 6637 | /* BGP route print out function. */ |
6638 | DEFUN (show_ip_bgp, | |
6639 | show_ip_bgp_cmd, | |
6640 | "show ip bgp", | |
6641 | SHOW_STR | |
6642 | IP_STR | |
6643 | BGP_STR) | |
6644 | { | |
5a646650 | 6645 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6646 | } |
6647 | ||
6648 | DEFUN (show_ip_bgp_ipv4, | |
6649 | show_ip_bgp_ipv4_cmd, | |
6650 | "show ip bgp ipv4 (unicast|multicast)", | |
6651 | SHOW_STR | |
6652 | IP_STR | |
6653 | BGP_STR | |
6654 | "Address family\n" | |
6655 | "Address Family modifier\n" | |
6656 | "Address Family modifier\n") | |
6657 | { | |
6658 | if (strncmp (argv[0], "m", 1) == 0) | |
5a646650 | 6659 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
6660 | NULL); | |
718e3744 | 6661 | |
5a646650 | 6662 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6663 | } |
6664 | ||
6665 | DEFUN (show_ip_bgp_route, | |
6666 | show_ip_bgp_route_cmd, | |
6667 | "show ip bgp A.B.C.D", | |
6668 | SHOW_STR | |
6669 | IP_STR | |
6670 | BGP_STR | |
6671 | "Network in the BGP routing table to display\n") | |
6672 | { | |
6673 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6674 | } | |
6675 | ||
6676 | DEFUN (show_ip_bgp_ipv4_route, | |
6677 | show_ip_bgp_ipv4_route_cmd, | |
6678 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", | |
6679 | SHOW_STR | |
6680 | IP_STR | |
6681 | BGP_STR | |
6682 | "Address family\n" | |
6683 | "Address Family modifier\n" | |
6684 | "Address Family modifier\n" | |
6685 | "Network in the BGP routing table to display\n") | |
6686 | { | |
6687 | if (strncmp (argv[0], "m", 1) == 0) | |
6688 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); | |
6689 | ||
6690 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6691 | } | |
6692 | ||
6693 | DEFUN (show_ip_bgp_vpnv4_all_route, | |
6694 | show_ip_bgp_vpnv4_all_route_cmd, | |
6695 | "show ip bgp vpnv4 all A.B.C.D", | |
6696 | SHOW_STR | |
6697 | IP_STR | |
6698 | BGP_STR | |
6699 | "Display VPNv4 NLRI specific information\n" | |
6700 | "Display information about all VPNv4 NLRIs\n" | |
6701 | "Network in the BGP routing table to display\n") | |
6702 | { | |
6703 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); | |
6704 | } | |
6705 | ||
6706 | DEFUN (show_ip_bgp_vpnv4_rd_route, | |
6707 | show_ip_bgp_vpnv4_rd_route_cmd, | |
6708 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", | |
6709 | SHOW_STR | |
6710 | IP_STR | |
6711 | BGP_STR | |
6712 | "Display VPNv4 NLRI specific information\n" | |
6713 | "Display information for a route distinguisher\n" | |
6714 | "VPN Route Distinguisher\n" | |
6715 | "Network in the BGP routing table to display\n") | |
6716 | { | |
6717 | int ret; | |
6718 | struct prefix_rd prd; | |
6719 | ||
6720 | ret = str2prefix_rd (argv[0], &prd); | |
6721 | if (! ret) | |
6722 | { | |
6723 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6724 | return CMD_WARNING; | |
6725 | } | |
6726 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); | |
6727 | } | |
6728 | ||
6729 | DEFUN (show_ip_bgp_prefix, | |
6730 | show_ip_bgp_prefix_cmd, | |
6731 | "show ip bgp A.B.C.D/M", | |
6732 | SHOW_STR | |
6733 | IP_STR | |
6734 | BGP_STR | |
6735 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6736 | { | |
6737 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6738 | } | |
6739 | ||
6740 | DEFUN (show_ip_bgp_ipv4_prefix, | |
6741 | show_ip_bgp_ipv4_prefix_cmd, | |
6742 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6743 | SHOW_STR | |
6744 | IP_STR | |
6745 | BGP_STR | |
6746 | "Address family\n" | |
6747 | "Address Family modifier\n" | |
6748 | "Address Family modifier\n" | |
6749 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6750 | { | |
6751 | if (strncmp (argv[0], "m", 1) == 0) | |
6752 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); | |
6753 | ||
6754 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6755 | } | |
6756 | ||
6757 | DEFUN (show_ip_bgp_vpnv4_all_prefix, | |
6758 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
6759 | "show ip bgp vpnv4 all A.B.C.D/M", | |
6760 | SHOW_STR | |
6761 | IP_STR | |
6762 | BGP_STR | |
6763 | "Display VPNv4 NLRI specific information\n" | |
6764 | "Display information about all VPNv4 NLRIs\n" | |
6765 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6766 | { | |
6767 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); | |
6768 | } | |
6769 | ||
6770 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
6771 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
6772 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", | |
6773 | SHOW_STR | |
6774 | IP_STR | |
6775 | BGP_STR | |
6776 | "Display VPNv4 NLRI specific information\n" | |
6777 | "Display information for a route distinguisher\n" | |
6778 | "VPN Route Distinguisher\n" | |
6779 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6780 | { | |
6781 | int ret; | |
6782 | struct prefix_rd prd; | |
6783 | ||
6784 | ret = str2prefix_rd (argv[0], &prd); | |
6785 | if (! ret) | |
6786 | { | |
6787 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6788 | return CMD_WARNING; | |
6789 | } | |
6790 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); | |
6791 | } | |
6792 | ||
6793 | DEFUN (show_ip_bgp_view, | |
6794 | show_ip_bgp_view_cmd, | |
6795 | "show ip bgp view WORD", | |
6796 | SHOW_STR | |
6797 | IP_STR | |
6798 | BGP_STR | |
6799 | "BGP view\n" | |
6800 | "BGP view name\n") | |
6801 | { | |
bb46e94f | 6802 | struct bgp *bgp; |
6803 | ||
6804 | /* BGP structure lookup. */ | |
6805 | bgp = bgp_lookup_by_name (argv[0]); | |
6806 | if (bgp == NULL) | |
6807 | { | |
6808 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6809 | return CMD_WARNING; | |
6810 | } | |
6811 | ||
5a646650 | 6812 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6813 | } |
6814 | ||
6815 | DEFUN (show_ip_bgp_view_route, | |
6816 | show_ip_bgp_view_route_cmd, | |
6817 | "show ip bgp view WORD A.B.C.D", | |
6818 | SHOW_STR | |
6819 | IP_STR | |
6820 | BGP_STR | |
6821 | "BGP view\n" | |
6822 | "BGP view name\n" | |
6823 | "Network in the BGP routing table to display\n") | |
6824 | { | |
6825 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6826 | } | |
6827 | ||
6828 | DEFUN (show_ip_bgp_view_prefix, | |
6829 | show_ip_bgp_view_prefix_cmd, | |
6830 | "show ip bgp view WORD A.B.C.D/M", | |
6831 | SHOW_STR | |
6832 | IP_STR | |
6833 | BGP_STR | |
6834 | "BGP view\n" | |
6835 | "BGP view name\n" | |
6836 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6837 | { | |
6838 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6839 | } | |
6840 | ||
6841 | #ifdef HAVE_IPV6 | |
6842 | DEFUN (show_bgp, | |
6843 | show_bgp_cmd, | |
6844 | "show bgp", | |
6845 | SHOW_STR | |
6846 | BGP_STR) | |
6847 | { | |
5a646650 | 6848 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6849 | NULL); | |
718e3744 | 6850 | } |
6851 | ||
6852 | ALIAS (show_bgp, | |
6853 | show_bgp_ipv6_cmd, | |
6854 | "show bgp ipv6", | |
6855 | SHOW_STR | |
6856 | BGP_STR | |
6857 | "Address family\n") | |
6858 | ||
6859 | /* old command */ | |
6860 | DEFUN (show_ipv6_bgp, | |
6861 | show_ipv6_bgp_cmd, | |
6862 | "show ipv6 bgp", | |
6863 | SHOW_STR | |
6864 | IP_STR | |
6865 | BGP_STR) | |
6866 | { | |
5a646650 | 6867 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6868 | NULL); | |
718e3744 | 6869 | } |
6870 | ||
6871 | DEFUN (show_bgp_route, | |
6872 | show_bgp_route_cmd, | |
6873 | "show bgp X:X::X:X", | |
6874 | SHOW_STR | |
6875 | BGP_STR | |
6876 | "Network in the BGP routing table to display\n") | |
6877 | { | |
6878 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6879 | } | |
6880 | ||
6881 | ALIAS (show_bgp_route, | |
6882 | show_bgp_ipv6_route_cmd, | |
6883 | "show bgp ipv6 X:X::X:X", | |
6884 | SHOW_STR | |
6885 | BGP_STR | |
6886 | "Address family\n" | |
6887 | "Network in the BGP routing table to display\n") | |
6888 | ||
6889 | /* old command */ | |
6890 | DEFUN (show_ipv6_bgp_route, | |
6891 | show_ipv6_bgp_route_cmd, | |
6892 | "show ipv6 bgp X:X::X:X", | |
6893 | SHOW_STR | |
6894 | IP_STR | |
6895 | BGP_STR | |
6896 | "Network in the BGP routing table to display\n") | |
6897 | { | |
6898 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6899 | } | |
6900 | ||
6901 | DEFUN (show_bgp_prefix, | |
6902 | show_bgp_prefix_cmd, | |
6903 | "show bgp X:X::X:X/M", | |
6904 | SHOW_STR | |
6905 | BGP_STR | |
6906 | "IPv6 prefix <network>/<length>\n") | |
6907 | { | |
6908 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6909 | } | |
6910 | ||
6911 | ALIAS (show_bgp_prefix, | |
6912 | show_bgp_ipv6_prefix_cmd, | |
6913 | "show bgp ipv6 X:X::X:X/M", | |
6914 | SHOW_STR | |
6915 | BGP_STR | |
6916 | "Address family\n" | |
6917 | "IPv6 prefix <network>/<length>\n") | |
6918 | ||
6919 | /* old command */ | |
6920 | DEFUN (show_ipv6_bgp_prefix, | |
6921 | show_ipv6_bgp_prefix_cmd, | |
6922 | "show ipv6 bgp X:X::X:X/M", | |
6923 | SHOW_STR | |
6924 | IP_STR | |
6925 | BGP_STR | |
6926 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6927 | { | |
6928 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6929 | } | |
6930 | ||
bb46e94f | 6931 | DEFUN (show_bgp_view, |
6932 | show_bgp_view_cmd, | |
6933 | "show bgp view WORD", | |
6934 | SHOW_STR | |
6935 | BGP_STR | |
6936 | "BGP view\n" | |
6937 | "View name\n") | |
6938 | { | |
6939 | struct bgp *bgp; | |
6940 | ||
6941 | /* BGP structure lookup. */ | |
6942 | bgp = bgp_lookup_by_name (argv[0]); | |
6943 | if (bgp == NULL) | |
6944 | { | |
6945 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6946 | return CMD_WARNING; | |
6947 | } | |
6948 | ||
5a646650 | 6949 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
bb46e94f | 6950 | } |
6951 | ||
6952 | ALIAS (show_bgp_view, | |
6953 | show_bgp_view_ipv6_cmd, | |
6954 | "show bgp view WORD ipv6", | |
6955 | SHOW_STR | |
6956 | BGP_STR | |
6957 | "BGP view\n" | |
6958 | "View name\n" | |
6959 | "Address family\n") | |
6960 | ||
6961 | DEFUN (show_bgp_view_route, | |
6962 | show_bgp_view_route_cmd, | |
6963 | "show bgp view WORD X:X::X:X", | |
6964 | SHOW_STR | |
6965 | BGP_STR | |
6966 | "BGP view\n" | |
6967 | "View name\n" | |
6968 | "Network in the BGP routing table to display\n") | |
6969 | { | |
6970 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6971 | } | |
6972 | ||
6973 | ALIAS (show_bgp_view_route, | |
6974 | show_bgp_view_ipv6_route_cmd, | |
6975 | "show bgp view WORD ipv6 X:X::X:X", | |
6976 | SHOW_STR | |
6977 | BGP_STR | |
6978 | "BGP view\n" | |
6979 | "View name\n" | |
6980 | "Address family\n" | |
6981 | "Network in the BGP routing table to display\n") | |
6982 | ||
6983 | DEFUN (show_bgp_view_prefix, | |
6984 | show_bgp_view_prefix_cmd, | |
6985 | "show bgp view WORD X:X::X:X/M", | |
6986 | SHOW_STR | |
6987 | BGP_STR | |
6988 | "BGP view\n" | |
6989 | "View name\n" | |
6990 | "IPv6 prefix <network>/<length>\n") | |
6991 | { | |
6992 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6993 | } | |
6994 | ||
6995 | ALIAS (show_bgp_view_prefix, | |
6996 | show_bgp_view_ipv6_prefix_cmd, | |
6997 | "show bgp view WORD ipv6 X:X::X:X/M", | |
6998 | SHOW_STR | |
6999 | BGP_STR | |
7000 | "BGP view\n" | |
7001 | "View name\n" | |
7002 | "Address family\n" | |
7003 | "IPv6 prefix <network>/<length>\n") | |
7004 | ||
718e3744 | 7005 | /* old command */ |
7006 | DEFUN (show_ipv6_mbgp, | |
7007 | show_ipv6_mbgp_cmd, | |
7008 | "show ipv6 mbgp", | |
7009 | SHOW_STR | |
7010 | IP_STR | |
7011 | MBGP_STR) | |
7012 | { | |
5a646650 | 7013 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
7014 | NULL); | |
718e3744 | 7015 | } |
7016 | ||
7017 | /* old command */ | |
7018 | DEFUN (show_ipv6_mbgp_route, | |
7019 | show_ipv6_mbgp_route_cmd, | |
7020 | "show ipv6 mbgp X:X::X:X", | |
7021 | SHOW_STR | |
7022 | IP_STR | |
7023 | MBGP_STR | |
7024 | "Network in the MBGP routing table to display\n") | |
7025 | { | |
7026 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
7027 | } | |
7028 | ||
7029 | /* old command */ | |
7030 | DEFUN (show_ipv6_mbgp_prefix, | |
7031 | show_ipv6_mbgp_prefix_cmd, | |
7032 | "show ipv6 mbgp X:X::X:X/M", | |
7033 | SHOW_STR | |
7034 | IP_STR | |
7035 | MBGP_STR | |
7036 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
7037 | { | |
7038 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
7039 | } | |
7040 | #endif | |
7041 | \f | |
718e3744 | 7042 | |
94f2b392 | 7043 | static int |
fd79ac91 | 7044 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 7045 | safi_t safi, enum bgp_show_type type) |
7046 | { | |
7047 | int i; | |
7048 | struct buffer *b; | |
7049 | char *regstr; | |
7050 | int first; | |
7051 | regex_t *regex; | |
5a646650 | 7052 | int rc; |
718e3744 | 7053 | |
7054 | first = 0; | |
7055 | b = buffer_new (1024); | |
7056 | for (i = 0; i < argc; i++) | |
7057 | { | |
7058 | if (first) | |
7059 | buffer_putc (b, ' '); | |
7060 | else | |
7061 | { | |
7062 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7063 | continue; | |
7064 | first = 1; | |
7065 | } | |
7066 | ||
7067 | buffer_putstr (b, argv[i]); | |
7068 | } | |
7069 | buffer_putc (b, '\0'); | |
7070 | ||
7071 | regstr = buffer_getstr (b); | |
7072 | buffer_free (b); | |
7073 | ||
7074 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 7075 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 7076 | if (! regex) |
7077 | { | |
7078 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
7079 | VTY_NEWLINE); | |
7080 | return CMD_WARNING; | |
7081 | } | |
7082 | ||
5a646650 | 7083 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
7084 | bgp_regex_free (regex); | |
7085 | return rc; | |
718e3744 | 7086 | } |
7087 | ||
7088 | DEFUN (show_ip_bgp_regexp, | |
7089 | show_ip_bgp_regexp_cmd, | |
7090 | "show ip bgp regexp .LINE", | |
7091 | SHOW_STR | |
7092 | IP_STR | |
7093 | BGP_STR | |
7094 | "Display routes matching the AS path regular expression\n" | |
7095 | "A regular-expression to match the BGP AS paths\n") | |
7096 | { | |
7097 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7098 | bgp_show_type_regexp); | |
7099 | } | |
7100 | ||
7101 | DEFUN (show_ip_bgp_flap_regexp, | |
7102 | show_ip_bgp_flap_regexp_cmd, | |
7103 | "show ip bgp flap-statistics regexp .LINE", | |
7104 | SHOW_STR | |
7105 | IP_STR | |
7106 | BGP_STR | |
7107 | "Display flap statistics of routes\n" | |
7108 | "Display routes matching the AS path regular expression\n" | |
7109 | "A regular-expression to match the BGP AS paths\n") | |
7110 | { | |
7111 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7112 | bgp_show_type_flap_regexp); | |
7113 | } | |
7114 | ||
7115 | DEFUN (show_ip_bgp_ipv4_regexp, | |
7116 | show_ip_bgp_ipv4_regexp_cmd, | |
7117 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
7118 | SHOW_STR | |
7119 | IP_STR | |
7120 | BGP_STR | |
7121 | "Address family\n" | |
7122 | "Address Family modifier\n" | |
7123 | "Address Family modifier\n" | |
7124 | "Display routes matching the AS path regular expression\n" | |
7125 | "A regular-expression to match the BGP AS paths\n") | |
7126 | { | |
7127 | if (strncmp (argv[0], "m", 1) == 0) | |
7128 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
7129 | bgp_show_type_regexp); | |
7130 | ||
7131 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7132 | bgp_show_type_regexp); | |
7133 | } | |
7134 | ||
7135 | #ifdef HAVE_IPV6 | |
7136 | DEFUN (show_bgp_regexp, | |
7137 | show_bgp_regexp_cmd, | |
7138 | "show bgp regexp .LINE", | |
7139 | SHOW_STR | |
7140 | BGP_STR | |
7141 | "Display routes matching the AS path regular expression\n" | |
7142 | "A regular-expression to match the BGP AS paths\n") | |
7143 | { | |
7144 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7145 | bgp_show_type_regexp); | |
7146 | } | |
7147 | ||
7148 | ALIAS (show_bgp_regexp, | |
7149 | show_bgp_ipv6_regexp_cmd, | |
7150 | "show bgp ipv6 regexp .LINE", | |
7151 | SHOW_STR | |
7152 | BGP_STR | |
7153 | "Address family\n" | |
7154 | "Display routes matching the AS path regular expression\n" | |
7155 | "A regular-expression to match the BGP AS paths\n") | |
7156 | ||
7157 | /* old command */ | |
7158 | DEFUN (show_ipv6_bgp_regexp, | |
7159 | show_ipv6_bgp_regexp_cmd, | |
7160 | "show ipv6 bgp regexp .LINE", | |
7161 | SHOW_STR | |
7162 | IP_STR | |
7163 | BGP_STR | |
7164 | "Display routes matching the AS path regular expression\n" | |
7165 | "A regular-expression to match the BGP AS paths\n") | |
7166 | { | |
7167 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7168 | bgp_show_type_regexp); | |
7169 | } | |
7170 | ||
7171 | /* old command */ | |
7172 | DEFUN (show_ipv6_mbgp_regexp, | |
7173 | show_ipv6_mbgp_regexp_cmd, | |
7174 | "show ipv6 mbgp regexp .LINE", | |
7175 | SHOW_STR | |
7176 | IP_STR | |
7177 | BGP_STR | |
7178 | "Display routes matching the AS path regular expression\n" | |
7179 | "A regular-expression to match the MBGP AS paths\n") | |
7180 | { | |
7181 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, | |
7182 | bgp_show_type_regexp); | |
7183 | } | |
7184 | #endif /* HAVE_IPV6 */ | |
7185 | \f | |
94f2b392 | 7186 | static int |
fd79ac91 | 7187 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
718e3744 | 7188 | safi_t safi, enum bgp_show_type type) |
7189 | { | |
7190 | struct prefix_list *plist; | |
7191 | ||
7192 | plist = prefix_list_lookup (afi, prefix_list_str); | |
7193 | if (plist == NULL) | |
7194 | { | |
7195 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
7196 | prefix_list_str, VTY_NEWLINE); | |
7197 | return CMD_WARNING; | |
7198 | } | |
7199 | ||
5a646650 | 7200 | return bgp_show (vty, NULL, afi, safi, type, plist); |
718e3744 | 7201 | } |
7202 | ||
7203 | DEFUN (show_ip_bgp_prefix_list, | |
7204 | show_ip_bgp_prefix_list_cmd, | |
7205 | "show ip bgp prefix-list WORD", | |
7206 | SHOW_STR | |
7207 | IP_STR | |
7208 | BGP_STR | |
7209 | "Display routes conforming to the prefix-list\n" | |
7210 | "IP prefix-list name\n") | |
7211 | { | |
7212 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7213 | bgp_show_type_prefix_list); | |
7214 | } | |
7215 | ||
7216 | DEFUN (show_ip_bgp_flap_prefix_list, | |
7217 | show_ip_bgp_flap_prefix_list_cmd, | |
7218 | "show ip bgp flap-statistics prefix-list WORD", | |
7219 | SHOW_STR | |
7220 | IP_STR | |
7221 | BGP_STR | |
7222 | "Display flap statistics of routes\n" | |
7223 | "Display routes conforming to the prefix-list\n" | |
7224 | "IP prefix-list name\n") | |
7225 | { | |
7226 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7227 | bgp_show_type_flap_prefix_list); | |
7228 | } | |
7229 | ||
7230 | DEFUN (show_ip_bgp_ipv4_prefix_list, | |
7231 | show_ip_bgp_ipv4_prefix_list_cmd, | |
7232 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
7233 | SHOW_STR | |
7234 | IP_STR | |
7235 | BGP_STR | |
7236 | "Address family\n" | |
7237 | "Address Family modifier\n" | |
7238 | "Address Family modifier\n" | |
7239 | "Display routes conforming to the prefix-list\n" | |
7240 | "IP prefix-list name\n") | |
7241 | { | |
7242 | if (strncmp (argv[0], "m", 1) == 0) | |
7243 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7244 | bgp_show_type_prefix_list); | |
7245 | ||
7246 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7247 | bgp_show_type_prefix_list); | |
7248 | } | |
7249 | ||
7250 | #ifdef HAVE_IPV6 | |
7251 | DEFUN (show_bgp_prefix_list, | |
7252 | show_bgp_prefix_list_cmd, | |
7253 | "show bgp prefix-list WORD", | |
7254 | SHOW_STR | |
7255 | BGP_STR | |
7256 | "Display routes conforming to the prefix-list\n" | |
7257 | "IPv6 prefix-list name\n") | |
7258 | { | |
7259 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7260 | bgp_show_type_prefix_list); | |
7261 | } | |
7262 | ||
7263 | ALIAS (show_bgp_prefix_list, | |
7264 | show_bgp_ipv6_prefix_list_cmd, | |
7265 | "show bgp ipv6 prefix-list WORD", | |
7266 | SHOW_STR | |
7267 | BGP_STR | |
7268 | "Address family\n" | |
7269 | "Display routes conforming to the prefix-list\n" | |
7270 | "IPv6 prefix-list name\n") | |
7271 | ||
7272 | /* old command */ | |
7273 | DEFUN (show_ipv6_bgp_prefix_list, | |
7274 | show_ipv6_bgp_prefix_list_cmd, | |
7275 | "show ipv6 bgp prefix-list WORD", | |
7276 | SHOW_STR | |
7277 | IPV6_STR | |
7278 | BGP_STR | |
7279 | "Display routes matching the prefix-list\n" | |
7280 | "IPv6 prefix-list name\n") | |
7281 | { | |
7282 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7283 | bgp_show_type_prefix_list); | |
7284 | } | |
7285 | ||
7286 | /* old command */ | |
7287 | DEFUN (show_ipv6_mbgp_prefix_list, | |
7288 | show_ipv6_mbgp_prefix_list_cmd, | |
7289 | "show ipv6 mbgp prefix-list WORD", | |
7290 | SHOW_STR | |
7291 | IPV6_STR | |
7292 | MBGP_STR | |
7293 | "Display routes matching the prefix-list\n" | |
7294 | "IPv6 prefix-list name\n") | |
7295 | { | |
7296 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7297 | bgp_show_type_prefix_list); | |
7298 | } | |
7299 | #endif /* HAVE_IPV6 */ | |
7300 | \f | |
94f2b392 | 7301 | static int |
fd79ac91 | 7302 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
718e3744 | 7303 | safi_t safi, enum bgp_show_type type) |
7304 | { | |
7305 | struct as_list *as_list; | |
7306 | ||
7307 | as_list = as_list_lookup (filter); | |
7308 | if (as_list == NULL) | |
7309 | { | |
7310 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
7311 | return CMD_WARNING; | |
7312 | } | |
7313 | ||
5a646650 | 7314 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
718e3744 | 7315 | } |
7316 | ||
7317 | DEFUN (show_ip_bgp_filter_list, | |
7318 | show_ip_bgp_filter_list_cmd, | |
7319 | "show ip bgp filter-list WORD", | |
7320 | SHOW_STR | |
7321 | IP_STR | |
7322 | BGP_STR | |
7323 | "Display routes conforming to the filter-list\n" | |
7324 | "Regular expression access list name\n") | |
7325 | { | |
7326 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7327 | bgp_show_type_filter_list); | |
7328 | } | |
7329 | ||
7330 | DEFUN (show_ip_bgp_flap_filter_list, | |
7331 | show_ip_bgp_flap_filter_list_cmd, | |
7332 | "show ip bgp flap-statistics filter-list WORD", | |
7333 | SHOW_STR | |
7334 | IP_STR | |
7335 | BGP_STR | |
7336 | "Display flap statistics of routes\n" | |
7337 | "Display routes conforming to the filter-list\n" | |
7338 | "Regular expression access list name\n") | |
7339 | { | |
7340 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7341 | bgp_show_type_flap_filter_list); | |
7342 | } | |
7343 | ||
7344 | DEFUN (show_ip_bgp_ipv4_filter_list, | |
7345 | show_ip_bgp_ipv4_filter_list_cmd, | |
7346 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
7347 | SHOW_STR | |
7348 | IP_STR | |
7349 | BGP_STR | |
7350 | "Address family\n" | |
7351 | "Address Family modifier\n" | |
7352 | "Address Family modifier\n" | |
7353 | "Display routes conforming to the filter-list\n" | |
7354 | "Regular expression access list name\n") | |
7355 | { | |
7356 | if (strncmp (argv[0], "m", 1) == 0) | |
7357 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7358 | bgp_show_type_filter_list); | |
7359 | ||
7360 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7361 | bgp_show_type_filter_list); | |
7362 | } | |
7363 | ||
7364 | #ifdef HAVE_IPV6 | |
7365 | DEFUN (show_bgp_filter_list, | |
7366 | show_bgp_filter_list_cmd, | |
7367 | "show bgp filter-list WORD", | |
7368 | SHOW_STR | |
7369 | BGP_STR | |
7370 | "Display routes conforming to the filter-list\n" | |
7371 | "Regular expression access list name\n") | |
7372 | { | |
7373 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7374 | bgp_show_type_filter_list); | |
7375 | } | |
7376 | ||
7377 | ALIAS (show_bgp_filter_list, | |
7378 | show_bgp_ipv6_filter_list_cmd, | |
7379 | "show bgp ipv6 filter-list WORD", | |
7380 | SHOW_STR | |
7381 | BGP_STR | |
7382 | "Address family\n" | |
7383 | "Display routes conforming to the filter-list\n" | |
7384 | "Regular expression access list name\n") | |
7385 | ||
7386 | /* old command */ | |
7387 | DEFUN (show_ipv6_bgp_filter_list, | |
7388 | show_ipv6_bgp_filter_list_cmd, | |
7389 | "show ipv6 bgp filter-list WORD", | |
7390 | SHOW_STR | |
7391 | IPV6_STR | |
7392 | BGP_STR | |
7393 | "Display routes conforming to the filter-list\n" | |
7394 | "Regular expression access list name\n") | |
7395 | { | |
7396 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7397 | bgp_show_type_filter_list); | |
7398 | } | |
7399 | ||
7400 | /* old command */ | |
7401 | DEFUN (show_ipv6_mbgp_filter_list, | |
7402 | show_ipv6_mbgp_filter_list_cmd, | |
7403 | "show ipv6 mbgp filter-list WORD", | |
7404 | SHOW_STR | |
7405 | IPV6_STR | |
7406 | MBGP_STR | |
7407 | "Display routes conforming to the filter-list\n" | |
7408 | "Regular expression access list name\n") | |
7409 | { | |
7410 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7411 | bgp_show_type_filter_list); | |
7412 | } | |
7413 | #endif /* HAVE_IPV6 */ | |
7414 | \f | |
94f2b392 | 7415 | static int |
fd79ac91 | 7416 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
718e3744 | 7417 | safi_t safi, enum bgp_show_type type) |
7418 | { | |
7419 | struct route_map *rmap; | |
7420 | ||
7421 | rmap = route_map_lookup_by_name (rmap_str); | |
7422 | if (! rmap) | |
7423 | { | |
7424 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
7425 | rmap_str, VTY_NEWLINE); | |
7426 | return CMD_WARNING; | |
7427 | } | |
7428 | ||
5a646650 | 7429 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
718e3744 | 7430 | } |
7431 | ||
7432 | DEFUN (show_ip_bgp_route_map, | |
7433 | show_ip_bgp_route_map_cmd, | |
7434 | "show ip bgp route-map WORD", | |
7435 | SHOW_STR | |
7436 | IP_STR | |
7437 | BGP_STR | |
7438 | "Display routes matching the route-map\n" | |
7439 | "A route-map to match on\n") | |
7440 | { | |
7441 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7442 | bgp_show_type_route_map); | |
7443 | } | |
7444 | ||
7445 | DEFUN (show_ip_bgp_flap_route_map, | |
7446 | show_ip_bgp_flap_route_map_cmd, | |
7447 | "show ip bgp flap-statistics route-map WORD", | |
7448 | SHOW_STR | |
7449 | IP_STR | |
7450 | BGP_STR | |
7451 | "Display flap statistics of routes\n" | |
7452 | "Display routes matching the route-map\n" | |
7453 | "A route-map to match on\n") | |
7454 | { | |
7455 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7456 | bgp_show_type_flap_route_map); | |
7457 | } | |
7458 | ||
7459 | DEFUN (show_ip_bgp_ipv4_route_map, | |
7460 | show_ip_bgp_ipv4_route_map_cmd, | |
7461 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
7462 | SHOW_STR | |
7463 | IP_STR | |
7464 | BGP_STR | |
7465 | "Address family\n" | |
7466 | "Address Family modifier\n" | |
7467 | "Address Family modifier\n" | |
7468 | "Display routes matching the route-map\n" | |
7469 | "A route-map to match on\n") | |
7470 | { | |
7471 | if (strncmp (argv[0], "m", 1) == 0) | |
7472 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7473 | bgp_show_type_route_map); | |
7474 | ||
7475 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7476 | bgp_show_type_route_map); | |
7477 | } | |
7478 | ||
7479 | DEFUN (show_bgp_route_map, | |
7480 | show_bgp_route_map_cmd, | |
7481 | "show bgp route-map WORD", | |
7482 | SHOW_STR | |
7483 | BGP_STR | |
7484 | "Display routes matching the route-map\n" | |
7485 | "A route-map to match on\n") | |
7486 | { | |
7487 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7488 | bgp_show_type_route_map); | |
7489 | } | |
7490 | ||
7491 | ALIAS (show_bgp_route_map, | |
7492 | show_bgp_ipv6_route_map_cmd, | |
7493 | "show bgp ipv6 route-map WORD", | |
7494 | SHOW_STR | |
7495 | BGP_STR | |
7496 | "Address family\n" | |
7497 | "Display routes matching the route-map\n" | |
7498 | "A route-map to match on\n") | |
7499 | \f | |
7500 | DEFUN (show_ip_bgp_cidr_only, | |
7501 | show_ip_bgp_cidr_only_cmd, | |
7502 | "show ip bgp cidr-only", | |
7503 | SHOW_STR | |
7504 | IP_STR | |
7505 | BGP_STR | |
7506 | "Display only routes with non-natural netmasks\n") | |
7507 | { | |
7508 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7509 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7510 | } |
7511 | ||
7512 | DEFUN (show_ip_bgp_flap_cidr_only, | |
7513 | show_ip_bgp_flap_cidr_only_cmd, | |
7514 | "show ip bgp flap-statistics cidr-only", | |
7515 | SHOW_STR | |
7516 | IP_STR | |
7517 | BGP_STR | |
7518 | "Display flap statistics of routes\n" | |
7519 | "Display only routes with non-natural netmasks\n") | |
7520 | { | |
7521 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7522 | bgp_show_type_flap_cidr_only, NULL); |
718e3744 | 7523 | } |
7524 | ||
7525 | DEFUN (show_ip_bgp_ipv4_cidr_only, | |
7526 | show_ip_bgp_ipv4_cidr_only_cmd, | |
7527 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
7528 | SHOW_STR | |
7529 | IP_STR | |
7530 | BGP_STR | |
7531 | "Address family\n" | |
7532 | "Address Family modifier\n" | |
7533 | "Address Family modifier\n" | |
7534 | "Display only routes with non-natural netmasks\n") | |
7535 | { | |
7536 | if (strncmp (argv[0], "m", 1) == 0) | |
7537 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7538 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7539 | |
7540 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7541 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7542 | } |
7543 | \f | |
7544 | DEFUN (show_ip_bgp_community_all, | |
7545 | show_ip_bgp_community_all_cmd, | |
7546 | "show ip bgp community", | |
7547 | SHOW_STR | |
7548 | IP_STR | |
7549 | BGP_STR | |
7550 | "Display routes matching the communities\n") | |
7551 | { | |
7552 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7553 | bgp_show_type_community_all, NULL); |
718e3744 | 7554 | } |
7555 | ||
7556 | DEFUN (show_ip_bgp_ipv4_community_all, | |
7557 | show_ip_bgp_ipv4_community_all_cmd, | |
7558 | "show ip bgp ipv4 (unicast|multicast) community", | |
7559 | SHOW_STR | |
7560 | IP_STR | |
7561 | BGP_STR | |
7562 | "Address family\n" | |
7563 | "Address Family modifier\n" | |
7564 | "Address Family modifier\n" | |
7565 | "Display routes matching the communities\n") | |
7566 | { | |
7567 | if (strncmp (argv[0], "m", 1) == 0) | |
7568 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7569 | bgp_show_type_community_all, NULL); |
718e3744 | 7570 | |
7571 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7572 | bgp_show_type_community_all, NULL); |
718e3744 | 7573 | } |
7574 | ||
7575 | #ifdef HAVE_IPV6 | |
7576 | DEFUN (show_bgp_community_all, | |
7577 | show_bgp_community_all_cmd, | |
7578 | "show bgp community", | |
7579 | SHOW_STR | |
7580 | BGP_STR | |
7581 | "Display routes matching the communities\n") | |
7582 | { | |
7583 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7584 | bgp_show_type_community_all, NULL); |
718e3744 | 7585 | } |
7586 | ||
7587 | ALIAS (show_bgp_community_all, | |
7588 | show_bgp_ipv6_community_all_cmd, | |
7589 | "show bgp ipv6 community", | |
7590 | SHOW_STR | |
7591 | BGP_STR | |
7592 | "Address family\n" | |
7593 | "Display routes matching the communities\n") | |
7594 | ||
7595 | /* old command */ | |
7596 | DEFUN (show_ipv6_bgp_community_all, | |
7597 | show_ipv6_bgp_community_all_cmd, | |
7598 | "show ipv6 bgp community", | |
7599 | SHOW_STR | |
7600 | IPV6_STR | |
7601 | BGP_STR | |
7602 | "Display routes matching the communities\n") | |
7603 | { | |
7604 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7605 | bgp_show_type_community_all, NULL); |
718e3744 | 7606 | } |
7607 | ||
7608 | /* old command */ | |
7609 | DEFUN (show_ipv6_mbgp_community_all, | |
7610 | show_ipv6_mbgp_community_all_cmd, | |
7611 | "show ipv6 mbgp community", | |
7612 | SHOW_STR | |
7613 | IPV6_STR | |
7614 | MBGP_STR | |
7615 | "Display routes matching the communities\n") | |
7616 | { | |
7617 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, | |
5a646650 | 7618 | bgp_show_type_community_all, NULL); |
718e3744 | 7619 | } |
7620 | #endif /* HAVE_IPV6 */ | |
7621 | \f | |
94f2b392 | 7622 | static int |
fd79ac91 | 7623 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
7624 | u_int16_t afi, u_char safi) | |
718e3744 | 7625 | { |
7626 | struct community *com; | |
7627 | struct buffer *b; | |
7628 | int i; | |
7629 | char *str; | |
7630 | int first = 0; | |
7631 | ||
7632 | b = buffer_new (1024); | |
7633 | for (i = 0; i < argc; i++) | |
7634 | { | |
7635 | if (first) | |
7636 | buffer_putc (b, ' '); | |
7637 | else | |
7638 | { | |
7639 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7640 | continue; | |
7641 | first = 1; | |
7642 | } | |
7643 | ||
7644 | buffer_putstr (b, argv[i]); | |
7645 | } | |
7646 | buffer_putc (b, '\0'); | |
7647 | ||
7648 | str = buffer_getstr (b); | |
7649 | buffer_free (b); | |
7650 | ||
7651 | com = community_str2com (str); | |
3b8b1855 | 7652 | XFREE (MTYPE_TMP, str); |
718e3744 | 7653 | if (! com) |
7654 | { | |
7655 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
7656 | return CMD_WARNING; | |
7657 | } | |
7658 | ||
5a646650 | 7659 | return bgp_show (vty, NULL, afi, safi, |
7660 | (exact ? bgp_show_type_community_exact : | |
7661 | bgp_show_type_community), com); | |
718e3744 | 7662 | } |
7663 | ||
7664 | DEFUN (show_ip_bgp_community, | |
7665 | show_ip_bgp_community_cmd, | |
7666 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
7667 | SHOW_STR | |
7668 | IP_STR | |
7669 | BGP_STR | |
7670 | "Display routes matching the communities\n" | |
7671 | "community number\n" | |
7672 | "Do not send outside local AS (well-known community)\n" | |
7673 | "Do not advertise to any peer (well-known community)\n" | |
7674 | "Do not export to next AS (well-known community)\n") | |
7675 | { | |
7676 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); | |
7677 | } | |
7678 | ||
7679 | ALIAS (show_ip_bgp_community, | |
7680 | show_ip_bgp_community2_cmd, | |
7681 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (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 | "community number\n" | |
7691 | "Do not send outside local AS (well-known community)\n" | |
7692 | "Do not advertise to any peer (well-known community)\n" | |
7693 | "Do not export to next AS (well-known community)\n") | |
7694 | ||
7695 | ALIAS (show_ip_bgp_community, | |
7696 | show_ip_bgp_community3_cmd, | |
7697 | "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)", | |
7698 | SHOW_STR | |
7699 | IP_STR | |
7700 | BGP_STR | |
7701 | "Display routes matching the communities\n" | |
7702 | "community number\n" | |
7703 | "Do not send outside local AS (well-known community)\n" | |
7704 | "Do not advertise to any peer (well-known community)\n" | |
7705 | "Do not export to next AS (well-known community)\n" | |
7706 | "community number\n" | |
7707 | "Do not send outside local AS (well-known community)\n" | |
7708 | "Do not advertise to any peer (well-known community)\n" | |
7709 | "Do not export to next AS (well-known community)\n" | |
7710 | "community number\n" | |
7711 | "Do not send outside local AS (well-known community)\n" | |
7712 | "Do not advertise to any peer (well-known community)\n" | |
7713 | "Do not export to next AS (well-known community)\n") | |
7714 | ||
7715 | ALIAS (show_ip_bgp_community, | |
7716 | show_ip_bgp_community4_cmd, | |
7717 | "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)", | |
7718 | SHOW_STR | |
7719 | IP_STR | |
7720 | BGP_STR | |
7721 | "Display routes matching the communities\n" | |
7722 | "community number\n" | |
7723 | "Do not send outside local AS (well-known community)\n" | |
7724 | "Do not advertise to any peer (well-known community)\n" | |
7725 | "Do not export to next AS (well-known community)\n" | |
7726 | "community number\n" | |
7727 | "Do not send outside local AS (well-known community)\n" | |
7728 | "Do not advertise to any peer (well-known community)\n" | |
7729 | "Do not export to next AS (well-known community)\n" | |
7730 | "community number\n" | |
7731 | "Do not send outside local AS (well-known community)\n" | |
7732 | "Do not advertise to any peer (well-known community)\n" | |
7733 | "Do not export to next AS (well-known community)\n" | |
7734 | "community number\n" | |
7735 | "Do not send outside local AS (well-known community)\n" | |
7736 | "Do not advertise to any peer (well-known community)\n" | |
7737 | "Do not export to next AS (well-known community)\n") | |
7738 | ||
7739 | DEFUN (show_ip_bgp_ipv4_community, | |
7740 | show_ip_bgp_ipv4_community_cmd, | |
7741 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7742 | SHOW_STR | |
7743 | IP_STR | |
7744 | BGP_STR | |
7745 | "Address family\n" | |
7746 | "Address Family modifier\n" | |
7747 | "Address Family modifier\n" | |
7748 | "Display routes matching the communities\n" | |
7749 | "community number\n" | |
7750 | "Do not send outside local AS (well-known community)\n" | |
7751 | "Do not advertise to any peer (well-known community)\n" | |
7752 | "Do not export to next AS (well-known community)\n") | |
7753 | { | |
7754 | if (strncmp (argv[0], "m", 1) == 0) | |
7755 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); | |
7756 | ||
7757 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); | |
7758 | } | |
7759 | ||
7760 | ALIAS (show_ip_bgp_ipv4_community, | |
7761 | show_ip_bgp_ipv4_community2_cmd, | |
7762 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7763 | SHOW_STR | |
7764 | IP_STR | |
7765 | BGP_STR | |
7766 | "Address family\n" | |
7767 | "Address Family modifier\n" | |
7768 | "Address Family modifier\n" | |
7769 | "Display routes matching the communities\n" | |
7770 | "community number\n" | |
7771 | "Do not send outside local AS (well-known community)\n" | |
7772 | "Do not advertise to any peer (well-known community)\n" | |
7773 | "Do not export to next AS (well-known community)\n" | |
7774 | "community number\n" | |
7775 | "Do not send outside local AS (well-known community)\n" | |
7776 | "Do not advertise to any peer (well-known community)\n" | |
7777 | "Do not export to next AS (well-known community)\n") | |
7778 | ||
7779 | ALIAS (show_ip_bgp_ipv4_community, | |
7780 | show_ip_bgp_ipv4_community3_cmd, | |
7781 | "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)", | |
7782 | SHOW_STR | |
7783 | IP_STR | |
7784 | BGP_STR | |
7785 | "Address family\n" | |
7786 | "Address Family modifier\n" | |
7787 | "Address Family modifier\n" | |
7788 | "Display routes matching the communities\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 | "community number\n" | |
7794 | "Do not send outside local AS (well-known community)\n" | |
7795 | "Do not advertise to any peer (well-known community)\n" | |
7796 | "Do not export to next AS (well-known community)\n" | |
7797 | "community number\n" | |
7798 | "Do not send outside local AS (well-known community)\n" | |
7799 | "Do not advertise to any peer (well-known community)\n" | |
7800 | "Do not export to next AS (well-known community)\n") | |
7801 | ||
7802 | ALIAS (show_ip_bgp_ipv4_community, | |
7803 | show_ip_bgp_ipv4_community4_cmd, | |
7804 | "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)", | |
7805 | SHOW_STR | |
7806 | IP_STR | |
7807 | BGP_STR | |
7808 | "Address family\n" | |
7809 | "Address Family modifier\n" | |
7810 | "Address Family modifier\n" | |
7811 | "Display routes matching the communities\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 | "community number\n" | |
7817 | "Do not send outside local AS (well-known community)\n" | |
7818 | "Do not advertise to any peer (well-known community)\n" | |
7819 | "Do not export to next AS (well-known community)\n" | |
7820 | "community number\n" | |
7821 | "Do not send outside local AS (well-known community)\n" | |
7822 | "Do not advertise to any peer (well-known community)\n" | |
7823 | "Do not export to next AS (well-known community)\n" | |
7824 | "community number\n" | |
7825 | "Do not send outside local AS (well-known community)\n" | |
7826 | "Do not advertise to any peer (well-known community)\n" | |
7827 | "Do not export to next AS (well-known community)\n") | |
7828 | ||
7829 | DEFUN (show_ip_bgp_community_exact, | |
7830 | show_ip_bgp_community_exact_cmd, | |
7831 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7832 | SHOW_STR | |
7833 | IP_STR | |
7834 | BGP_STR | |
7835 | "Display routes matching the communities\n" | |
7836 | "community number\n" | |
7837 | "Do not send outside local AS (well-known community)\n" | |
7838 | "Do not advertise to any peer (well-known community)\n" | |
7839 | "Do not export to next AS (well-known community)\n" | |
7840 | "Exact match of the communities") | |
7841 | { | |
7842 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); | |
7843 | } | |
7844 | ||
7845 | ALIAS (show_ip_bgp_community_exact, | |
7846 | show_ip_bgp_community2_exact_cmd, | |
7847 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7848 | SHOW_STR | |
7849 | IP_STR | |
7850 | BGP_STR | |
7851 | "Display routes matching the communities\n" | |
7852 | "community number\n" | |
7853 | "Do not send outside local AS (well-known community)\n" | |
7854 | "Do not advertise to any peer (well-known community)\n" | |
7855 | "Do not export to next AS (well-known community)\n" | |
7856 | "community number\n" | |
7857 | "Do not send outside local AS (well-known community)\n" | |
7858 | "Do not advertise to any peer (well-known community)\n" | |
7859 | "Do not export to next AS (well-known community)\n" | |
7860 | "Exact match of the communities") | |
7861 | ||
7862 | ALIAS (show_ip_bgp_community_exact, | |
7863 | show_ip_bgp_community3_exact_cmd, | |
7864 | "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", | |
7865 | SHOW_STR | |
7866 | IP_STR | |
7867 | BGP_STR | |
7868 | "Display routes matching the communities\n" | |
7869 | "community number\n" | |
7870 | "Do not send outside local AS (well-known community)\n" | |
7871 | "Do not advertise to any peer (well-known community)\n" | |
7872 | "Do not export to next AS (well-known community)\n" | |
7873 | "community number\n" | |
7874 | "Do not send outside local AS (well-known community)\n" | |
7875 | "Do not advertise to any peer (well-known community)\n" | |
7876 | "Do not export to next AS (well-known community)\n" | |
7877 | "community number\n" | |
7878 | "Do not send outside local AS (well-known community)\n" | |
7879 | "Do not advertise to any peer (well-known community)\n" | |
7880 | "Do not export to next AS (well-known community)\n" | |
7881 | "Exact match of the communities") | |
7882 | ||
7883 | ALIAS (show_ip_bgp_community_exact, | |
7884 | show_ip_bgp_community4_exact_cmd, | |
7885 | "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", | |
7886 | SHOW_STR | |
7887 | IP_STR | |
7888 | BGP_STR | |
7889 | "Display routes matching the communities\n" | |
7890 | "community number\n" | |
7891 | "Do not send outside local AS (well-known community)\n" | |
7892 | "Do not advertise to any peer (well-known community)\n" | |
7893 | "Do not export to next AS (well-known community)\n" | |
7894 | "community number\n" | |
7895 | "Do not send outside local AS (well-known community)\n" | |
7896 | "Do not advertise to any peer (well-known community)\n" | |
7897 | "Do not export to next AS (well-known community)\n" | |
7898 | "community number\n" | |
7899 | "Do not send outside local AS (well-known community)\n" | |
7900 | "Do not advertise to any peer (well-known community)\n" | |
7901 | "Do not export to next AS (well-known community)\n" | |
7902 | "community number\n" | |
7903 | "Do not send outside local AS (well-known community)\n" | |
7904 | "Do not advertise to any peer (well-known community)\n" | |
7905 | "Do not export to next AS (well-known community)\n" | |
7906 | "Exact match of the communities") | |
7907 | ||
7908 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
7909 | show_ip_bgp_ipv4_community_exact_cmd, | |
7910 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7911 | SHOW_STR | |
7912 | IP_STR | |
7913 | BGP_STR | |
7914 | "Address family\n" | |
7915 | "Address Family modifier\n" | |
7916 | "Address Family modifier\n" | |
7917 | "Display routes matching the communities\n" | |
7918 | "community number\n" | |
7919 | "Do not send outside local AS (well-known community)\n" | |
7920 | "Do not advertise to any peer (well-known community)\n" | |
7921 | "Do not export to next AS (well-known community)\n" | |
7922 | "Exact match of the communities") | |
7923 | { | |
7924 | if (strncmp (argv[0], "m", 1) == 0) | |
7925 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); | |
7926 | ||
7927 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); | |
7928 | } | |
7929 | ||
7930 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
7931 | show_ip_bgp_ipv4_community2_exact_cmd, | |
7932 | "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", | |
7933 | SHOW_STR | |
7934 | IP_STR | |
7935 | BGP_STR | |
7936 | "Address family\n" | |
7937 | "Address Family modifier\n" | |
7938 | "Address Family modifier\n" | |
7939 | "Display routes matching the communities\n" | |
7940 | "community number\n" | |
7941 | "Do not send outside local AS (well-known community)\n" | |
7942 | "Do not advertise to any peer (well-known community)\n" | |
7943 | "Do not export to next AS (well-known community)\n" | |
7944 | "community number\n" | |
7945 | "Do not send outside local AS (well-known community)\n" | |
7946 | "Do not advertise to any peer (well-known community)\n" | |
7947 | "Do not export to next AS (well-known community)\n" | |
7948 | "Exact match of the communities") | |
7949 | ||
7950 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
7951 | show_ip_bgp_ipv4_community3_exact_cmd, | |
7952 | "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", | |
7953 | SHOW_STR | |
7954 | IP_STR | |
7955 | BGP_STR | |
7956 | "Address family\n" | |
7957 | "Address Family modifier\n" | |
7958 | "Address Family modifier\n" | |
7959 | "Display routes matching the communities\n" | |
7960 | "community number\n" | |
7961 | "Do not send outside local AS (well-known community)\n" | |
7962 | "Do not advertise to any peer (well-known community)\n" | |
7963 | "Do not export to next AS (well-known community)\n" | |
7964 | "community number\n" | |
7965 | "Do not send outside local AS (well-known community)\n" | |
7966 | "Do not advertise to any peer (well-known community)\n" | |
7967 | "Do not export to next AS (well-known community)\n" | |
7968 | "community number\n" | |
7969 | "Do not send outside local AS (well-known community)\n" | |
7970 | "Do not advertise to any peer (well-known community)\n" | |
7971 | "Do not export to next AS (well-known community)\n" | |
7972 | "Exact match of the communities") | |
7973 | ||
7974 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
7975 | show_ip_bgp_ipv4_community4_exact_cmd, | |
7976 | "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", | |
7977 | SHOW_STR | |
7978 | IP_STR | |
7979 | BGP_STR | |
7980 | "Address family\n" | |
7981 | "Address Family modifier\n" | |
7982 | "Address Family modifier\n" | |
7983 | "Display routes matching the communities\n" | |
7984 | "community number\n" | |
7985 | "Do not send outside local AS (well-known community)\n" | |
7986 | "Do not advertise to any peer (well-known community)\n" | |
7987 | "Do not export to next AS (well-known community)\n" | |
7988 | "community number\n" | |
7989 | "Do not send outside local AS (well-known community)\n" | |
7990 | "Do not advertise to any peer (well-known community)\n" | |
7991 | "Do not export to next AS (well-known community)\n" | |
7992 | "community number\n" | |
7993 | "Do not send outside local AS (well-known community)\n" | |
7994 | "Do not advertise to any peer (well-known community)\n" | |
7995 | "Do not export to next AS (well-known community)\n" | |
7996 | "community number\n" | |
7997 | "Do not send outside local AS (well-known community)\n" | |
7998 | "Do not advertise to any peer (well-known community)\n" | |
7999 | "Do not export to next AS (well-known community)\n" | |
8000 | "Exact match of the communities") | |
8001 | ||
8002 | #ifdef HAVE_IPV6 | |
8003 | DEFUN (show_bgp_community, | |
8004 | show_bgp_community_cmd, | |
8005 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8006 | SHOW_STR | |
8007 | BGP_STR | |
8008 | "Display routes matching the communities\n" | |
8009 | "community number\n" | |
8010 | "Do not send outside local AS (well-known community)\n" | |
8011 | "Do not advertise to any peer (well-known community)\n" | |
8012 | "Do not export to next AS (well-known community)\n") | |
8013 | { | |
8014 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); | |
8015 | } | |
8016 | ||
8017 | ALIAS (show_bgp_community, | |
8018 | show_bgp_ipv6_community_cmd, | |
8019 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
8020 | SHOW_STR | |
8021 | BGP_STR | |
8022 | "Address family\n" | |
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 | ALIAS (show_bgp_community, | |
8030 | show_bgp_community2_cmd, | |
8031 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8032 | SHOW_STR | |
8033 | BGP_STR | |
8034 | "Display routes matching the communities\n" | |
8035 | "community number\n" | |
8036 | "Do not send outside local AS (well-known community)\n" | |
8037 | "Do not advertise to any peer (well-known community)\n" | |
8038 | "Do not export to next AS (well-known community)\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_ipv6_community2_cmd, | |
8046 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8047 | SHOW_STR | |
8048 | BGP_STR | |
8049 | "Address family\n" | |
8050 | "Display routes matching the communities\n" | |
8051 | "community number\n" | |
8052 | "Do not send outside local AS (well-known community)\n" | |
8053 | "Do not advertise to any peer (well-known community)\n" | |
8054 | "Do not export to next AS (well-known community)\n" | |
8055 | "community number\n" | |
8056 | "Do not send outside local AS (well-known community)\n" | |
8057 | "Do not advertise to any peer (well-known community)\n" | |
8058 | "Do not export to next AS (well-known community)\n") | |
8059 | ||
8060 | ALIAS (show_bgp_community, | |
8061 | show_bgp_community3_cmd, | |
8062 | "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)", | |
8063 | SHOW_STR | |
8064 | BGP_STR | |
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 | "community number\n" | |
8075 | "Do not send outside local AS (well-known community)\n" | |
8076 | "Do not advertise to any peer (well-known community)\n" | |
8077 | "Do not export to next AS (well-known community)\n") | |
8078 | ||
8079 | ALIAS (show_bgp_community, | |
8080 | show_bgp_ipv6_community3_cmd, | |
8081 | "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)", | |
8082 | SHOW_STR | |
8083 | BGP_STR | |
8084 | "Address family\n" | |
8085 | "Display routes matching the communities\n" | |
8086 | "community number\n" | |
8087 | "Do not send outside local AS (well-known community)\n" | |
8088 | "Do not advertise to any peer (well-known community)\n" | |
8089 | "Do not export to next AS (well-known community)\n" | |
8090 | "community number\n" | |
8091 | "Do not send outside local AS (well-known community)\n" | |
8092 | "Do not advertise to any peer (well-known community)\n" | |
8093 | "Do not export to next AS (well-known community)\n" | |
8094 | "community number\n" | |
8095 | "Do not send outside local AS (well-known community)\n" | |
8096 | "Do not advertise to any peer (well-known community)\n" | |
8097 | "Do not export to next AS (well-known community)\n") | |
8098 | ||
8099 | ALIAS (show_bgp_community, | |
8100 | show_bgp_community4_cmd, | |
8101 | "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)", | |
8102 | SHOW_STR | |
8103 | BGP_STR | |
8104 | "Display routes matching the communities\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 | "community number\n" | |
8114 | "Do not send outside local AS (well-known community)\n" | |
8115 | "Do not advertise to any peer (well-known community)\n" | |
8116 | "Do not export to next AS (well-known community)\n" | |
8117 | "community number\n" | |
8118 | "Do not send outside local AS (well-known community)\n" | |
8119 | "Do not advertise to any peer (well-known community)\n" | |
8120 | "Do not export to next AS (well-known community)\n") | |
8121 | ||
8122 | ALIAS (show_bgp_community, | |
8123 | show_bgp_ipv6_community4_cmd, | |
8124 | "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)", | |
8125 | SHOW_STR | |
8126 | BGP_STR | |
8127 | "Address family\n" | |
8128 | "Display routes matching the communities\n" | |
8129 | "community number\n" | |
8130 | "Do not send outside local AS (well-known community)\n" | |
8131 | "Do not advertise to any peer (well-known community)\n" | |
8132 | "Do not export to next AS (well-known community)\n" | |
8133 | "community number\n" | |
8134 | "Do not send outside local AS (well-known community)\n" | |
8135 | "Do not advertise to any peer (well-known community)\n" | |
8136 | "Do not export to next AS (well-known community)\n" | |
8137 | "community number\n" | |
8138 | "Do not send outside local AS (well-known community)\n" | |
8139 | "Do not advertise to any peer (well-known community)\n" | |
8140 | "Do not export to next AS (well-known community)\n" | |
8141 | "community number\n" | |
8142 | "Do not send outside local AS (well-known community)\n" | |
8143 | "Do not advertise to any peer (well-known community)\n" | |
8144 | "Do not export to next AS (well-known community)\n") | |
8145 | ||
8146 | /* old command */ | |
8147 | DEFUN (show_ipv6_bgp_community, | |
8148 | show_ipv6_bgp_community_cmd, | |
8149 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8150 | SHOW_STR | |
8151 | IPV6_STR | |
8152 | BGP_STR | |
8153 | "Display routes matching the communities\n" | |
8154 | "community number\n" | |
8155 | "Do not send outside local AS (well-known community)\n" | |
8156 | "Do not advertise to any peer (well-known community)\n" | |
8157 | "Do not export to next AS (well-known community)\n") | |
8158 | { | |
8159 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); | |
8160 | } | |
8161 | ||
8162 | /* old command */ | |
8163 | ALIAS (show_ipv6_bgp_community, | |
8164 | show_ipv6_bgp_community2_cmd, | |
8165 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8166 | SHOW_STR | |
8167 | IPV6_STR | |
8168 | BGP_STR | |
8169 | "Display routes matching the communities\n" | |
8170 | "community number\n" | |
8171 | "Do not send outside local AS (well-known community)\n" | |
8172 | "Do not advertise to any peer (well-known community)\n" | |
8173 | "Do not export to next AS (well-known community)\n" | |
8174 | "community number\n" | |
8175 | "Do not send outside local AS (well-known community)\n" | |
8176 | "Do not advertise to any peer (well-known community)\n" | |
8177 | "Do not export to next AS (well-known community)\n") | |
8178 | ||
8179 | /* old command */ | |
8180 | ALIAS (show_ipv6_bgp_community, | |
8181 | show_ipv6_bgp_community3_cmd, | |
8182 | "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)", | |
8183 | SHOW_STR | |
8184 | IPV6_STR | |
8185 | BGP_STR | |
8186 | "Display routes matching the communities\n" | |
8187 | "community number\n" | |
8188 | "Do not send outside local AS (well-known community)\n" | |
8189 | "Do not advertise to any peer (well-known community)\n" | |
8190 | "Do not export to next AS (well-known community)\n" | |
8191 | "community number\n" | |
8192 | "Do not send outside local AS (well-known community)\n" | |
8193 | "Do not advertise to any peer (well-known community)\n" | |
8194 | "Do not export to next AS (well-known community)\n" | |
8195 | "community number\n" | |
8196 | "Do not send outside local AS (well-known community)\n" | |
8197 | "Do not advertise to any peer (well-known community)\n" | |
8198 | "Do not export to next AS (well-known community)\n") | |
8199 | ||
8200 | /* old command */ | |
8201 | ALIAS (show_ipv6_bgp_community, | |
8202 | show_ipv6_bgp_community4_cmd, | |
8203 | "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)", | |
8204 | SHOW_STR | |
8205 | IPV6_STR | |
8206 | BGP_STR | |
8207 | "Display routes matching the communities\n" | |
8208 | "community number\n" | |
8209 | "Do not send outside local AS (well-known community)\n" | |
8210 | "Do not advertise to any peer (well-known community)\n" | |
8211 | "Do not export to next AS (well-known community)\n" | |
8212 | "community number\n" | |
8213 | "Do not send outside local AS (well-known community)\n" | |
8214 | "Do not advertise to any peer (well-known community)\n" | |
8215 | "Do not export to next AS (well-known community)\n" | |
8216 | "community number\n" | |
8217 | "Do not send outside local AS (well-known community)\n" | |
8218 | "Do not advertise to any peer (well-known community)\n" | |
8219 | "Do not export to next AS (well-known community)\n" | |
8220 | "community number\n" | |
8221 | "Do not send outside local AS (well-known community)\n" | |
8222 | "Do not advertise to any peer (well-known community)\n" | |
8223 | "Do not export to next AS (well-known community)\n") | |
8224 | ||
8225 | DEFUN (show_bgp_community_exact, | |
8226 | show_bgp_community_exact_cmd, | |
8227 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8228 | SHOW_STR | |
8229 | BGP_STR | |
8230 | "Display routes matching the communities\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 | "Exact match of the communities") | |
8236 | { | |
8237 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); | |
8238 | } | |
8239 | ||
8240 | ALIAS (show_bgp_community_exact, | |
8241 | show_bgp_ipv6_community_exact_cmd, | |
8242 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8243 | SHOW_STR | |
8244 | BGP_STR | |
8245 | "Address family\n" | |
8246 | "Display routes matching the communities\n" | |
8247 | "community number\n" | |
8248 | "Do not send outside local AS (well-known community)\n" | |
8249 | "Do not advertise to any peer (well-known community)\n" | |
8250 | "Do not export to next AS (well-known community)\n" | |
8251 | "Exact match of the communities") | |
8252 | ||
8253 | ALIAS (show_bgp_community_exact, | |
8254 | show_bgp_community2_exact_cmd, | |
8255 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8256 | SHOW_STR | |
8257 | BGP_STR | |
8258 | "Display routes matching the communities\n" | |
8259 | "community number\n" | |
8260 | "Do not send outside local AS (well-known community)\n" | |
8261 | "Do not advertise to any peer (well-known community)\n" | |
8262 | "Do not export to next AS (well-known community)\n" | |
8263 | "community number\n" | |
8264 | "Do not send outside local AS (well-known community)\n" | |
8265 | "Do not advertise to any peer (well-known community)\n" | |
8266 | "Do not export to next AS (well-known community)\n" | |
8267 | "Exact match of the communities") | |
8268 | ||
8269 | ALIAS (show_bgp_community_exact, | |
8270 | show_bgp_ipv6_community2_exact_cmd, | |
8271 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8272 | SHOW_STR | |
8273 | BGP_STR | |
8274 | "Address family\n" | |
8275 | "Display routes matching the communities\n" | |
8276 | "community number\n" | |
8277 | "Do not send outside local AS (well-known community)\n" | |
8278 | "Do not advertise to any peer (well-known community)\n" | |
8279 | "Do not export to next AS (well-known community)\n" | |
8280 | "community number\n" | |
8281 | "Do not send outside local AS (well-known community)\n" | |
8282 | "Do not advertise to any peer (well-known community)\n" | |
8283 | "Do not export to next AS (well-known community)\n" | |
8284 | "Exact match of the communities") | |
8285 | ||
8286 | ALIAS (show_bgp_community_exact, | |
8287 | show_bgp_community3_exact_cmd, | |
8288 | "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", | |
8289 | SHOW_STR | |
8290 | BGP_STR | |
8291 | "Display routes matching the communities\n" | |
8292 | "community number\n" | |
8293 | "Do not send outside local AS (well-known community)\n" | |
8294 | "Do not advertise to any peer (well-known community)\n" | |
8295 | "Do not export to next AS (well-known community)\n" | |
8296 | "community number\n" | |
8297 | "Do not send outside local AS (well-known community)\n" | |
8298 | "Do not advertise to any peer (well-known community)\n" | |
8299 | "Do not export to next AS (well-known community)\n" | |
8300 | "community number\n" | |
8301 | "Do not send outside local AS (well-known community)\n" | |
8302 | "Do not advertise to any peer (well-known community)\n" | |
8303 | "Do not export to next AS (well-known community)\n" | |
8304 | "Exact match of the communities") | |
8305 | ||
8306 | ALIAS (show_bgp_community_exact, | |
8307 | show_bgp_ipv6_community3_exact_cmd, | |
8308 | "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", | |
8309 | SHOW_STR | |
8310 | BGP_STR | |
8311 | "Address family\n" | |
8312 | "Display routes matching the communities\n" | |
8313 | "community number\n" | |
8314 | "Do not send outside local AS (well-known community)\n" | |
8315 | "Do not advertise to any peer (well-known community)\n" | |
8316 | "Do not export to next AS (well-known community)\n" | |
8317 | "community number\n" | |
8318 | "Do not send outside local AS (well-known community)\n" | |
8319 | "Do not advertise to any peer (well-known community)\n" | |
8320 | "Do not export to next AS (well-known community)\n" | |
8321 | "community number\n" | |
8322 | "Do not send outside local AS (well-known community)\n" | |
8323 | "Do not advertise to any peer (well-known community)\n" | |
8324 | "Do not export to next AS (well-known community)\n" | |
8325 | "Exact match of the communities") | |
8326 | ||
8327 | ALIAS (show_bgp_community_exact, | |
8328 | show_bgp_community4_exact_cmd, | |
8329 | "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", | |
8330 | SHOW_STR | |
8331 | BGP_STR | |
8332 | "Display routes matching the communities\n" | |
8333 | "community number\n" | |
8334 | "Do not send outside local AS (well-known community)\n" | |
8335 | "Do not advertise to any peer (well-known community)\n" | |
8336 | "Do not export to next AS (well-known community)\n" | |
8337 | "community number\n" | |
8338 | "Do not send outside local AS (well-known community)\n" | |
8339 | "Do not advertise to any peer (well-known community)\n" | |
8340 | "Do not export to next AS (well-known community)\n" | |
8341 | "community number\n" | |
8342 | "Do not send outside local AS (well-known community)\n" | |
8343 | "Do not advertise to any peer (well-known community)\n" | |
8344 | "Do not export to next AS (well-known community)\n" | |
8345 | "community number\n" | |
8346 | "Do not send outside local AS (well-known community)\n" | |
8347 | "Do not advertise to any peer (well-known community)\n" | |
8348 | "Do not export to next AS (well-known community)\n" | |
8349 | "Exact match of the communities") | |
8350 | ||
8351 | ALIAS (show_bgp_community_exact, | |
8352 | show_bgp_ipv6_community4_exact_cmd, | |
8353 | "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", | |
8354 | SHOW_STR | |
8355 | BGP_STR | |
8356 | "Address family\n" | |
8357 | "Display routes matching the communities\n" | |
8358 | "community number\n" | |
8359 | "Do not send outside local AS (well-known community)\n" | |
8360 | "Do not advertise to any peer (well-known community)\n" | |
8361 | "Do not export to next AS (well-known community)\n" | |
8362 | "community number\n" | |
8363 | "Do not send outside local AS (well-known community)\n" | |
8364 | "Do not advertise to any peer (well-known community)\n" | |
8365 | "Do not export to next AS (well-known community)\n" | |
8366 | "community number\n" | |
8367 | "Do not send outside local AS (well-known community)\n" | |
8368 | "Do not advertise to any peer (well-known community)\n" | |
8369 | "Do not export to next AS (well-known community)\n" | |
8370 | "community number\n" | |
8371 | "Do not send outside local AS (well-known community)\n" | |
8372 | "Do not advertise to any peer (well-known community)\n" | |
8373 | "Do not export to next AS (well-known community)\n" | |
8374 | "Exact match of the communities") | |
8375 | ||
8376 | /* old command */ | |
8377 | DEFUN (show_ipv6_bgp_community_exact, | |
8378 | show_ipv6_bgp_community_exact_cmd, | |
8379 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8380 | SHOW_STR | |
8381 | IPV6_STR | |
8382 | BGP_STR | |
8383 | "Display routes matching the communities\n" | |
8384 | "community number\n" | |
8385 | "Do not send outside local AS (well-known community)\n" | |
8386 | "Do not advertise to any peer (well-known community)\n" | |
8387 | "Do not export to next AS (well-known community)\n" | |
8388 | "Exact match of the communities") | |
8389 | { | |
8390 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); | |
8391 | } | |
8392 | ||
8393 | /* old command */ | |
8394 | ALIAS (show_ipv6_bgp_community_exact, | |
8395 | show_ipv6_bgp_community2_exact_cmd, | |
8396 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8397 | SHOW_STR | |
8398 | IPV6_STR | |
8399 | BGP_STR | |
8400 | "Display routes matching the communities\n" | |
8401 | "community number\n" | |
8402 | "Do not send outside local AS (well-known community)\n" | |
8403 | "Do not advertise to any peer (well-known community)\n" | |
8404 | "Do not export to next AS (well-known community)\n" | |
8405 | "community number\n" | |
8406 | "Do not send outside local AS (well-known community)\n" | |
8407 | "Do not advertise to any peer (well-known community)\n" | |
8408 | "Do not export to next AS (well-known community)\n" | |
8409 | "Exact match of the communities") | |
8410 | ||
8411 | /* old command */ | |
8412 | ALIAS (show_ipv6_bgp_community_exact, | |
8413 | show_ipv6_bgp_community3_exact_cmd, | |
8414 | "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", | |
8415 | SHOW_STR | |
8416 | IPV6_STR | |
8417 | BGP_STR | |
8418 | "Display routes matching the communities\n" | |
8419 | "community number\n" | |
8420 | "Do not send outside local AS (well-known community)\n" | |
8421 | "Do not advertise to any peer (well-known community)\n" | |
8422 | "Do not export to next AS (well-known community)\n" | |
8423 | "community number\n" | |
8424 | "Do not send outside local AS (well-known community)\n" | |
8425 | "Do not advertise to any peer (well-known community)\n" | |
8426 | "Do not export to next AS (well-known community)\n" | |
8427 | "community number\n" | |
8428 | "Do not send outside local AS (well-known community)\n" | |
8429 | "Do not advertise to any peer (well-known community)\n" | |
8430 | "Do not export to next AS (well-known community)\n" | |
8431 | "Exact match of the communities") | |
8432 | ||
8433 | /* old command */ | |
8434 | ALIAS (show_ipv6_bgp_community_exact, | |
8435 | show_ipv6_bgp_community4_exact_cmd, | |
8436 | "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", | |
8437 | SHOW_STR | |
8438 | IPV6_STR | |
8439 | BGP_STR | |
8440 | "Display routes matching the communities\n" | |
8441 | "community number\n" | |
8442 | "Do not send outside local AS (well-known community)\n" | |
8443 | "Do not advertise to any peer (well-known community)\n" | |
8444 | "Do not export to next AS (well-known community)\n" | |
8445 | "community number\n" | |
8446 | "Do not send outside local AS (well-known community)\n" | |
8447 | "Do not advertise to any peer (well-known community)\n" | |
8448 | "Do not export to next AS (well-known community)\n" | |
8449 | "community number\n" | |
8450 | "Do not send outside local AS (well-known community)\n" | |
8451 | "Do not advertise to any peer (well-known community)\n" | |
8452 | "Do not export to next AS (well-known community)\n" | |
8453 | "community number\n" | |
8454 | "Do not send outside local AS (well-known community)\n" | |
8455 | "Do not advertise to any peer (well-known community)\n" | |
8456 | "Do not export to next AS (well-known community)\n" | |
8457 | "Exact match of the communities") | |
8458 | ||
8459 | /* old command */ | |
8460 | DEFUN (show_ipv6_mbgp_community, | |
8461 | show_ipv6_mbgp_community_cmd, | |
8462 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8463 | SHOW_STR | |
8464 | IPV6_STR | |
8465 | MBGP_STR | |
8466 | "Display routes matching the communities\n" | |
8467 | "community number\n" | |
8468 | "Do not send outside local AS (well-known community)\n" | |
8469 | "Do not advertise to any peer (well-known community)\n" | |
8470 | "Do not export to next AS (well-known community)\n") | |
8471 | { | |
8472 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); | |
8473 | } | |
8474 | ||
8475 | /* old command */ | |
8476 | ALIAS (show_ipv6_mbgp_community, | |
8477 | show_ipv6_mbgp_community2_cmd, | |
8478 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8479 | SHOW_STR | |
8480 | IPV6_STR | |
8481 | MBGP_STR | |
8482 | "Display routes matching the communities\n" | |
8483 | "community number\n" | |
8484 | "Do not send outside local AS (well-known community)\n" | |
8485 | "Do not advertise to any peer (well-known community)\n" | |
8486 | "Do not export to next AS (well-known community)\n" | |
8487 | "community number\n" | |
8488 | "Do not send outside local AS (well-known community)\n" | |
8489 | "Do not advertise to any peer (well-known community)\n" | |
8490 | "Do not export to next AS (well-known community)\n") | |
8491 | ||
8492 | /* old command */ | |
8493 | ALIAS (show_ipv6_mbgp_community, | |
8494 | show_ipv6_mbgp_community3_cmd, | |
8495 | "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)", | |
8496 | SHOW_STR | |
8497 | IPV6_STR | |
8498 | MBGP_STR | |
8499 | "Display routes matching the communities\n" | |
8500 | "community number\n" | |
8501 | "Do not send outside local AS (well-known community)\n" | |
8502 | "Do not advertise to any peer (well-known community)\n" | |
8503 | "Do not export to next AS (well-known community)\n" | |
8504 | "community number\n" | |
8505 | "Do not send outside local AS (well-known community)\n" | |
8506 | "Do not advertise to any peer (well-known community)\n" | |
8507 | "Do not export to next AS (well-known community)\n" | |
8508 | "community number\n" | |
8509 | "Do not send outside local AS (well-known community)\n" | |
8510 | "Do not advertise to any peer (well-known community)\n" | |
8511 | "Do not export to next AS (well-known community)\n") | |
8512 | ||
8513 | /* old command */ | |
8514 | ALIAS (show_ipv6_mbgp_community, | |
8515 | show_ipv6_mbgp_community4_cmd, | |
8516 | "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)", | |
8517 | SHOW_STR | |
8518 | IPV6_STR | |
8519 | MBGP_STR | |
8520 | "Display routes matching the communities\n" | |
8521 | "community number\n" | |
8522 | "Do not send outside local AS (well-known community)\n" | |
8523 | "Do not advertise to any peer (well-known community)\n" | |
8524 | "Do not export to next AS (well-known community)\n" | |
8525 | "community number\n" | |
8526 | "Do not send outside local AS (well-known community)\n" | |
8527 | "Do not advertise to any peer (well-known community)\n" | |
8528 | "Do not export to next AS (well-known community)\n" | |
8529 | "community number\n" | |
8530 | "Do not send outside local AS (well-known community)\n" | |
8531 | "Do not advertise to any peer (well-known community)\n" | |
8532 | "Do not export to next AS (well-known community)\n" | |
8533 | "community number\n" | |
8534 | "Do not send outside local AS (well-known community)\n" | |
8535 | "Do not advertise to any peer (well-known community)\n" | |
8536 | "Do not export to next AS (well-known community)\n") | |
8537 | ||
8538 | /* old command */ | |
8539 | DEFUN (show_ipv6_mbgp_community_exact, | |
8540 | show_ipv6_mbgp_community_exact_cmd, | |
8541 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8542 | SHOW_STR | |
8543 | IPV6_STR | |
8544 | MBGP_STR | |
8545 | "Display routes matching the communities\n" | |
8546 | "community number\n" | |
8547 | "Do not send outside local AS (well-known community)\n" | |
8548 | "Do not advertise to any peer (well-known community)\n" | |
8549 | "Do not export to next AS (well-known community)\n" | |
8550 | "Exact match of the communities") | |
8551 | { | |
8552 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); | |
8553 | } | |
8554 | ||
8555 | /* old command */ | |
8556 | ALIAS (show_ipv6_mbgp_community_exact, | |
8557 | show_ipv6_mbgp_community2_exact_cmd, | |
8558 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8559 | SHOW_STR | |
8560 | IPV6_STR | |
8561 | MBGP_STR | |
8562 | "Display routes matching the communities\n" | |
8563 | "community number\n" | |
8564 | "Do not send outside local AS (well-known community)\n" | |
8565 | "Do not advertise to any peer (well-known community)\n" | |
8566 | "Do not export to next AS (well-known community)\n" | |
8567 | "community number\n" | |
8568 | "Do not send outside local AS (well-known community)\n" | |
8569 | "Do not advertise to any peer (well-known community)\n" | |
8570 | "Do not export to next AS (well-known community)\n" | |
8571 | "Exact match of the communities") | |
8572 | ||
8573 | /* old command */ | |
8574 | ALIAS (show_ipv6_mbgp_community_exact, | |
8575 | show_ipv6_mbgp_community3_exact_cmd, | |
8576 | "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", | |
8577 | SHOW_STR | |
8578 | IPV6_STR | |
8579 | MBGP_STR | |
8580 | "Display routes matching the communities\n" | |
8581 | "community number\n" | |
8582 | "Do not send outside local AS (well-known community)\n" | |
8583 | "Do not advertise to any peer (well-known community)\n" | |
8584 | "Do not export to next AS (well-known community)\n" | |
8585 | "community number\n" | |
8586 | "Do not send outside local AS (well-known community)\n" | |
8587 | "Do not advertise to any peer (well-known community)\n" | |
8588 | "Do not export to next AS (well-known community)\n" | |
8589 | "community number\n" | |
8590 | "Do not send outside local AS (well-known community)\n" | |
8591 | "Do not advertise to any peer (well-known community)\n" | |
8592 | "Do not export to next AS (well-known community)\n" | |
8593 | "Exact match of the communities") | |
8594 | ||
8595 | /* old command */ | |
8596 | ALIAS (show_ipv6_mbgp_community_exact, | |
8597 | show_ipv6_mbgp_community4_exact_cmd, | |
8598 | "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", | |
8599 | SHOW_STR | |
8600 | IPV6_STR | |
8601 | MBGP_STR | |
8602 | "Display routes matching the communities\n" | |
8603 | "community number\n" | |
8604 | "Do not send outside local AS (well-known community)\n" | |
8605 | "Do not advertise to any peer (well-known community)\n" | |
8606 | "Do not export to next AS (well-known community)\n" | |
8607 | "community number\n" | |
8608 | "Do not send outside local AS (well-known community)\n" | |
8609 | "Do not advertise to any peer (well-known community)\n" | |
8610 | "Do not export to next AS (well-known community)\n" | |
8611 | "community number\n" | |
8612 | "Do not send outside local AS (well-known community)\n" | |
8613 | "Do not advertise to any peer (well-known community)\n" | |
8614 | "Do not export to next AS (well-known community)\n" | |
8615 | "community number\n" | |
8616 | "Do not send outside local AS (well-known community)\n" | |
8617 | "Do not advertise to any peer (well-known community)\n" | |
8618 | "Do not export to next AS (well-known community)\n" | |
8619 | "Exact match of the communities") | |
8620 | #endif /* HAVE_IPV6 */ | |
8621 | \f | |
94f2b392 | 8622 | static int |
fd79ac91 | 8623 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
718e3744 | 8624 | u_int16_t afi, u_char safi) |
8625 | { | |
8626 | struct community_list *list; | |
8627 | ||
fee6e4e4 | 8628 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 8629 | if (list == NULL) |
8630 | { | |
8631 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
8632 | VTY_NEWLINE); | |
8633 | return CMD_WARNING; | |
8634 | } | |
8635 | ||
5a646650 | 8636 | return bgp_show (vty, NULL, afi, safi, |
8637 | (exact ? bgp_show_type_community_list_exact : | |
8638 | bgp_show_type_community_list), list); | |
718e3744 | 8639 | } |
8640 | ||
8641 | DEFUN (show_ip_bgp_community_list, | |
8642 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 8643 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 8644 | SHOW_STR |
8645 | IP_STR | |
8646 | BGP_STR | |
8647 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8648 | "community-list number\n" |
718e3744 | 8649 | "community-list name\n") |
8650 | { | |
8651 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); | |
8652 | } | |
8653 | ||
8654 | DEFUN (show_ip_bgp_ipv4_community_list, | |
8655 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 8656 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 8657 | SHOW_STR |
8658 | IP_STR | |
8659 | BGP_STR | |
8660 | "Address family\n" | |
8661 | "Address Family modifier\n" | |
8662 | "Address Family modifier\n" | |
8663 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8664 | "community-list number\n" |
718e3744 | 8665 | "community-list name\n") |
8666 | { | |
8667 | if (strncmp (argv[0], "m", 1) == 0) | |
8668 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); | |
8669 | ||
8670 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); | |
8671 | } | |
8672 | ||
8673 | DEFUN (show_ip_bgp_community_list_exact, | |
8674 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8675 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8676 | SHOW_STR |
8677 | IP_STR | |
8678 | BGP_STR | |
8679 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8680 | "community-list number\n" |
718e3744 | 8681 | "community-list name\n" |
8682 | "Exact match of the communities\n") | |
8683 | { | |
8684 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); | |
8685 | } | |
8686 | ||
8687 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
8688 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 8689 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 8690 | SHOW_STR |
8691 | IP_STR | |
8692 | BGP_STR | |
8693 | "Address family\n" | |
8694 | "Address Family modifier\n" | |
8695 | "Address Family modifier\n" | |
8696 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8697 | "community-list number\n" |
718e3744 | 8698 | "community-list name\n" |
8699 | "Exact match of the communities\n") | |
8700 | { | |
8701 | if (strncmp (argv[0], "m", 1) == 0) | |
8702 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); | |
8703 | ||
8704 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); | |
8705 | } | |
8706 | ||
8707 | #ifdef HAVE_IPV6 | |
8708 | DEFUN (show_bgp_community_list, | |
8709 | show_bgp_community_list_cmd, | |
fee6e4e4 | 8710 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 8711 | SHOW_STR |
8712 | BGP_STR | |
8713 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8714 | "community-list number\n" |
718e3744 | 8715 | "community-list name\n") |
8716 | { | |
8717 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8718 | } | |
8719 | ||
8720 | ALIAS (show_bgp_community_list, | |
8721 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 8722 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 8723 | SHOW_STR |
8724 | BGP_STR | |
8725 | "Address family\n" | |
8726 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8727 | "community-list number\n" |
e8e1946e | 8728 | "community-list name\n") |
718e3744 | 8729 | |
8730 | /* old command */ | |
8731 | DEFUN (show_ipv6_bgp_community_list, | |
8732 | show_ipv6_bgp_community_list_cmd, | |
8733 | "show ipv6 bgp community-list WORD", | |
8734 | SHOW_STR | |
8735 | IPV6_STR | |
8736 | BGP_STR | |
8737 | "Display routes matching the community-list\n" | |
8738 | "community-list name\n") | |
8739 | { | |
8740 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8741 | } | |
8742 | ||
8743 | /* old command */ | |
8744 | DEFUN (show_ipv6_mbgp_community_list, | |
8745 | show_ipv6_mbgp_community_list_cmd, | |
8746 | "show ipv6 mbgp community-list WORD", | |
8747 | SHOW_STR | |
8748 | IPV6_STR | |
8749 | MBGP_STR | |
8750 | "Display routes matching the community-list\n" | |
8751 | "community-list name\n") | |
8752 | { | |
8753 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); | |
8754 | } | |
8755 | ||
8756 | DEFUN (show_bgp_community_list_exact, | |
8757 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8758 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8759 | SHOW_STR |
8760 | BGP_STR | |
8761 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8762 | "community-list number\n" |
718e3744 | 8763 | "community-list name\n" |
8764 | "Exact match of the communities\n") | |
8765 | { | |
8766 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8767 | } | |
8768 | ||
8769 | ALIAS (show_bgp_community_list_exact, | |
8770 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 8771 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 8772 | SHOW_STR |
8773 | BGP_STR | |
8774 | "Address family\n" | |
8775 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8776 | "community-list number\n" |
718e3744 | 8777 | "community-list name\n" |
8778 | "Exact match of the communities\n") | |
8779 | ||
8780 | /* old command */ | |
8781 | DEFUN (show_ipv6_bgp_community_list_exact, | |
8782 | show_ipv6_bgp_community_list_exact_cmd, | |
8783 | "show ipv6 bgp community-list WORD exact-match", | |
8784 | SHOW_STR | |
8785 | IPV6_STR | |
8786 | BGP_STR | |
8787 | "Display routes matching the community-list\n" | |
8788 | "community-list name\n" | |
8789 | "Exact match of the communities\n") | |
8790 | { | |
8791 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8792 | } | |
8793 | ||
8794 | /* old command */ | |
8795 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
8796 | show_ipv6_mbgp_community_list_exact_cmd, | |
8797 | "show ipv6 mbgp community-list WORD exact-match", | |
8798 | SHOW_STR | |
8799 | IPV6_STR | |
8800 | MBGP_STR | |
8801 | "Display routes matching the community-list\n" | |
8802 | "community-list name\n" | |
8803 | "Exact match of the communities\n") | |
8804 | { | |
8805 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); | |
8806 | } | |
8807 | #endif /* HAVE_IPV6 */ | |
8808 | \f | |
94f2b392 | 8809 | static int |
fd79ac91 | 8810 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
718e3744 | 8811 | safi_t safi, enum bgp_show_type type) |
8812 | { | |
8813 | int ret; | |
8814 | struct prefix *p; | |
8815 | ||
8816 | p = prefix_new(); | |
8817 | ||
8818 | ret = str2prefix (prefix, p); | |
8819 | if (! ret) | |
8820 | { | |
8821 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
8822 | return CMD_WARNING; | |
8823 | } | |
8824 | ||
5a646650 | 8825 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
8826 | prefix_free(p); | |
8827 | return ret; | |
718e3744 | 8828 | } |
8829 | ||
8830 | DEFUN (show_ip_bgp_prefix_longer, | |
8831 | show_ip_bgp_prefix_longer_cmd, | |
8832 | "show ip bgp A.B.C.D/M longer-prefixes", | |
8833 | SHOW_STR | |
8834 | IP_STR | |
8835 | BGP_STR | |
8836 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8837 | "Display route and more specific routes\n") | |
8838 | { | |
8839 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8840 | bgp_show_type_prefix_longer); | |
8841 | } | |
8842 | ||
8843 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
8844 | show_ip_bgp_flap_prefix_longer_cmd, | |
8845 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
8846 | SHOW_STR | |
8847 | IP_STR | |
8848 | BGP_STR | |
8849 | "Display flap statistics of routes\n" | |
8850 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8851 | "Display route and more specific routes\n") | |
8852 | { | |
8853 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8854 | bgp_show_type_flap_prefix_longer); | |
8855 | } | |
8856 | ||
8857 | DEFUN (show_ip_bgp_ipv4_prefix_longer, | |
8858 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
8859 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
8860 | SHOW_STR | |
8861 | IP_STR | |
8862 | BGP_STR | |
8863 | "Address family\n" | |
8864 | "Address Family modifier\n" | |
8865 | "Address Family modifier\n" | |
8866 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8867 | "Display route and more specific routes\n") | |
8868 | { | |
8869 | if (strncmp (argv[0], "m", 1) == 0) | |
8870 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
8871 | bgp_show_type_prefix_longer); | |
8872 | ||
8873 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
8874 | bgp_show_type_prefix_longer); | |
8875 | } | |
8876 | ||
8877 | DEFUN (show_ip_bgp_flap_address, | |
8878 | show_ip_bgp_flap_address_cmd, | |
8879 | "show ip bgp flap-statistics A.B.C.D", | |
8880 | SHOW_STR | |
8881 | IP_STR | |
8882 | BGP_STR | |
8883 | "Display flap statistics of routes\n" | |
8884 | "Network in the BGP routing table to display\n") | |
8885 | { | |
8886 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8887 | bgp_show_type_flap_address); | |
8888 | } | |
8889 | ||
8890 | DEFUN (show_ip_bgp_flap_prefix, | |
8891 | show_ip_bgp_flap_prefix_cmd, | |
8892 | "show ip bgp flap-statistics A.B.C.D/M", | |
8893 | SHOW_STR | |
8894 | IP_STR | |
8895 | BGP_STR | |
8896 | "Display flap statistics of routes\n" | |
8897 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
8898 | { | |
8899 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8900 | bgp_show_type_flap_prefix); | |
8901 | } | |
8902 | #ifdef HAVE_IPV6 | |
8903 | DEFUN (show_bgp_prefix_longer, | |
8904 | show_bgp_prefix_longer_cmd, | |
8905 | "show bgp X:X::X:X/M longer-prefixes", | |
8906 | SHOW_STR | |
8907 | BGP_STR | |
8908 | "IPv6 prefix <network>/<length>\n" | |
8909 | "Display route and more specific routes\n") | |
8910 | { | |
8911 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
8912 | bgp_show_type_prefix_longer); | |
8913 | } | |
8914 | ||
8915 | ALIAS (show_bgp_prefix_longer, | |
8916 | show_bgp_ipv6_prefix_longer_cmd, | |
8917 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
8918 | SHOW_STR | |
8919 | BGP_STR | |
8920 | "Address family\n" | |
8921 | "IPv6 prefix <network>/<length>\n" | |
8922 | "Display route and more specific routes\n") | |
8923 | ||
8924 | /* old command */ | |
8925 | DEFUN (show_ipv6_bgp_prefix_longer, | |
8926 | show_ipv6_bgp_prefix_longer_cmd, | |
8927 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
8928 | SHOW_STR | |
8929 | IPV6_STR | |
8930 | BGP_STR | |
8931 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8932 | "Display route and more specific routes\n") | |
8933 | { | |
8934 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
8935 | bgp_show_type_prefix_longer); | |
8936 | } | |
8937 | ||
8938 | /* old command */ | |
8939 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
8940 | show_ipv6_mbgp_prefix_longer_cmd, | |
8941 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
8942 | SHOW_STR | |
8943 | IPV6_STR | |
8944 | MBGP_STR | |
8945 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8946 | "Display route and more specific routes\n") | |
8947 | { | |
8948 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
8949 | bgp_show_type_prefix_longer); | |
8950 | } | |
8951 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 8952 | |
94f2b392 | 8953 | static struct peer * |
fd79ac91 | 8954 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
8955 | const char *ip_str) | |
bb46e94f | 8956 | { |
8957 | int ret; | |
8958 | struct bgp *bgp; | |
8959 | struct peer *peer; | |
8960 | union sockunion su; | |
8961 | ||
8962 | /* BGP structure lookup. */ | |
8963 | if (view_name) | |
8964 | { | |
8965 | bgp = bgp_lookup_by_name (view_name); | |
8966 | if (! bgp) | |
8967 | { | |
8968 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
8969 | return NULL; | |
8970 | } | |
8971 | } | |
5228ad27 | 8972 | else |
bb46e94f | 8973 | { |
8974 | bgp = bgp_get_default (); | |
8975 | if (! bgp) | |
8976 | { | |
8977 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
8978 | return NULL; | |
8979 | } | |
8980 | } | |
8981 | ||
8982 | /* Get peer sockunion. */ | |
8983 | ret = str2sockunion (ip_str, &su); | |
8984 | if (ret < 0) | |
8985 | { | |
8986 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); | |
8987 | return NULL; | |
8988 | } | |
8989 | ||
8990 | /* Peer structure lookup. */ | |
8991 | peer = peer_lookup (bgp, &su); | |
8992 | if (! peer) | |
8993 | { | |
8994 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
8995 | return NULL; | |
8996 | } | |
8997 | ||
8998 | return peer; | |
8999 | } | |
2815e61f PJ |
9000 | \f |
9001 | enum bgp_stats | |
9002 | { | |
9003 | BGP_STATS_MAXBITLEN = 0, | |
9004 | BGP_STATS_RIB, | |
9005 | BGP_STATS_PREFIXES, | |
9006 | BGP_STATS_TOTPLEN, | |
9007 | BGP_STATS_UNAGGREGATEABLE, | |
9008 | BGP_STATS_MAX_AGGREGATEABLE, | |
9009 | BGP_STATS_AGGREGATES, | |
9010 | BGP_STATS_SPACE, | |
9011 | BGP_STATS_ASPATH_COUNT, | |
9012 | BGP_STATS_ASPATH_MAXHOPS, | |
9013 | BGP_STATS_ASPATH_TOTHOPS, | |
9014 | BGP_STATS_ASPATH_MAXSIZE, | |
9015 | BGP_STATS_ASPATH_TOTSIZE, | |
9016 | BGP_STATS_ASN_HIGHEST, | |
9017 | BGP_STATS_MAX, | |
9018 | }; | |
9019 | ||
9020 | static const char *table_stats_strs[] = | |
9021 | { | |
9022 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
9023 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
9024 | [BGP_STATS_RIB] = "Total Advertisements", | |
9025 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
9026 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
9027 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
9028 | [BGP_STATS_SPACE] = "Address space advertised", | |
9029 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
9030 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
9031 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
9032 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
9033 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
9034 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
9035 | [BGP_STATS_MAX] = NULL, | |
9036 | }; | |
9037 | ||
9038 | struct bgp_table_stats | |
9039 | { | |
9040 | struct bgp_table *table; | |
9041 | unsigned long long counts[BGP_STATS_MAX]; | |
9042 | }; | |
9043 | ||
9044 | #if 0 | |
9045 | #define TALLY_SIGFIG 100000 | |
9046 | static unsigned long | |
9047 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
9048 | { | |
9049 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
9050 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
9051 | unsigned long ret = newtot / count; | |
9052 | ||
9053 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
9054 | return ret + 1; | |
9055 | else | |
9056 | return ret; | |
9057 | } | |
9058 | #endif | |
9059 | ||
9060 | static int | |
9061 | bgp_table_stats_walker (struct thread *t) | |
9062 | { | |
9063 | struct bgp_node *rn; | |
9064 | struct bgp_node *top; | |
9065 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
9066 | unsigned int space = 0; | |
9067 | ||
53d9f67a PJ |
9068 | if (!(top = bgp_table_top (ts->table))) |
9069 | return 0; | |
2815e61f PJ |
9070 | |
9071 | switch (top->p.family) | |
9072 | { | |
9073 | case AF_INET: | |
9074 | space = IPV4_MAX_BITLEN; | |
9075 | break; | |
9076 | case AF_INET6: | |
9077 | space = IPV6_MAX_BITLEN; | |
9078 | break; | |
9079 | } | |
9080 | ||
9081 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
9082 | ||
9083 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
9084 | { | |
9085 | struct bgp_info *ri; | |
9086 | struct bgp_node *prn = rn->parent; | |
9087 | unsigned int rinum = 0; | |
9088 | ||
9089 | if (rn == top) | |
9090 | continue; | |
9091 | ||
9092 | if (!rn->info) | |
9093 | continue; | |
9094 | ||
9095 | ts->counts[BGP_STATS_PREFIXES]++; | |
9096 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
9097 | ||
9098 | #if 0 | |
9099 | ts->counts[BGP_STATS_AVGPLEN] | |
9100 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
9101 | ts->counts[BGP_STATS_AVGPLEN], | |
9102 | rn->p.prefixlen); | |
9103 | #endif | |
9104 | ||
9105 | /* check if the prefix is included by any other announcements */ | |
9106 | while (prn && !prn->info) | |
9107 | prn = prn->parent; | |
9108 | ||
9109 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
9110 | { |
9111 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
9112 | /* announced address space */ | |
9113 | if (space) | |
9114 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
9115 | } | |
2815e61f PJ |
9116 | else if (prn->info) |
9117 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
9118 | ||
2815e61f PJ |
9119 | for (ri = rn->info; ri; ri = ri->next) |
9120 | { | |
9121 | rinum++; | |
9122 | ts->counts[BGP_STATS_RIB]++; | |
9123 | ||
9124 | if (ri->attr && | |
9125 | (CHECK_FLAG (ri->attr->flag, | |
9126 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
9127 | ts->counts[BGP_STATS_AGGREGATES]++; | |
9128 | ||
9129 | /* as-path stats */ | |
9130 | if (ri->attr && ri->attr->aspath) | |
9131 | { | |
9132 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
9133 | unsigned int size = aspath_size (ri->attr->aspath); | |
9134 | as_t highest = aspath_highest (ri->attr->aspath); | |
9135 | ||
9136 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
9137 | ||
9138 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
9139 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
9140 | ||
9141 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
9142 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
9143 | ||
9144 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
9145 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
9146 | #if 0 | |
9147 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
9148 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9149 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
9150 | hops); | |
9151 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
9152 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9153 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
9154 | size); | |
9155 | #endif | |
9156 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
9157 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
9158 | } | |
9159 | } | |
9160 | } | |
9161 | return 0; | |
9162 | } | |
9163 | ||
9164 | static int | |
9165 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
9166 | { | |
9167 | struct bgp_table_stats ts; | |
9168 | unsigned int i; | |
9169 | ||
9170 | if (!bgp->rib[afi][safi]) | |
9171 | { | |
9172 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); | |
9173 | return CMD_WARNING; | |
9174 | } | |
9175 | ||
9176 | memset (&ts, 0, sizeof (ts)); | |
9177 | ts.table = bgp->rib[afi][safi]; | |
9178 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); | |
bb46e94f | 9179 | |
2815e61f PJ |
9180 | vty_out (vty, "BGP %s RIB statistics%s%s", |
9181 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
9182 | ||
9183 | for (i = 0; i < BGP_STATS_MAX; i++) | |
9184 | { | |
9185 | if (!table_stats_strs[i]) | |
9186 | continue; | |
9187 | ||
9188 | switch (i) | |
9189 | { | |
9190 | #if 0 | |
9191 | case BGP_STATS_ASPATH_AVGHOPS: | |
9192 | case BGP_STATS_ASPATH_AVGSIZE: | |
9193 | case BGP_STATS_AVGPLEN: | |
9194 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9195 | vty_out (vty, "%12.2f", | |
9196 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
9197 | break; | |
9198 | #endif | |
9199 | case BGP_STATS_ASPATH_TOTHOPS: | |
9200 | case BGP_STATS_ASPATH_TOTSIZE: | |
9201 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9202 | vty_out (vty, "%12.2f", | |
9203 | ts.counts[i] ? | |
9204 | (float)ts.counts[i] / | |
9205 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
9206 | : 0); | |
9207 | break; | |
9208 | case BGP_STATS_TOTPLEN: | |
9209 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9210 | vty_out (vty, "%12.2f", | |
9211 | ts.counts[i] ? | |
9212 | (float)ts.counts[i] / | |
9213 | (float)ts.counts[BGP_STATS_PREFIXES] | |
9214 | : 0); | |
9215 | break; | |
9216 | case BGP_STATS_SPACE: | |
9217 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9218 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
9219 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
9220 | break; | |
30a2231a | 9221 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
9222 | vty_out (vty, "%12.2f%s", |
9223 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 9224 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
9225 | VTY_NEWLINE); |
9226 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
9227 | vty_out (vty, "%12.2f%s", | |
9228 | (float)ts.counts[BGP_STATS_SPACE] / | |
9229 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
9230 | VTY_NEWLINE); | |
9231 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
9232 | break; | |
9233 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
9234 | vty_out (vty, "%12.2f", | |
9235 | (float)ts.counts[BGP_STATS_SPACE] / | |
9236 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
9237 | break; | |
9238 | default: | |
9239 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9240 | vty_out (vty, "%12llu", ts.counts[i]); | |
9241 | } | |
9242 | ||
9243 | vty_out (vty, "%s", VTY_NEWLINE); | |
9244 | } | |
9245 | return CMD_SUCCESS; | |
9246 | } | |
9247 | ||
9248 | static int | |
9249 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
9250 | const char *afi_str, const char *safi_str) | |
9251 | { | |
9252 | struct bgp *bgp; | |
9253 | afi_t afi; | |
9254 | safi_t safi; | |
9255 | ||
9256 | if (name) | |
9257 | bgp = bgp_lookup_by_name (name); | |
9258 | else | |
9259 | bgp = bgp_get_default (); | |
9260 | ||
9261 | if (!bgp) | |
9262 | { | |
9263 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9264 | return CMD_WARNING; | |
9265 | } | |
9266 | if (strncmp (afi_str, "ipv", 3) == 0) | |
9267 | { | |
9268 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
9269 | afi = AFI_IP; | |
9270 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
9271 | afi = AFI_IP6; | |
9272 | else | |
9273 | { | |
9274 | vty_out (vty, "%% Invalid address family %s%s", | |
9275 | afi_str, VTY_NEWLINE); | |
9276 | return CMD_WARNING; | |
9277 | } | |
9278 | if (strncmp (safi_str, "m", 1) == 0) | |
9279 | safi = SAFI_MULTICAST; | |
9280 | else if (strncmp (safi_str, "u", 1) == 0) | |
9281 | safi = SAFI_UNICAST; | |
9282 | else if (strncmp (safi_str, "vpnv4", 5) == 0) | |
9283 | safi = BGP_SAFI_VPNV4; | |
9284 | else if (strncmp (safi_str, "vpnv6", 6) == 0) | |
9285 | safi = BGP_SAFI_VPNV6; | |
9286 | else | |
9287 | { | |
9288 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
9289 | safi_str, VTY_NEWLINE); | |
9290 | return CMD_WARNING; | |
9291 | } | |
9292 | } | |
9293 | else | |
9294 | { | |
9295 | vty_out (vty, "%% Invalid address family %s%s", | |
9296 | afi_str, VTY_NEWLINE); | |
9297 | return CMD_WARNING; | |
9298 | } | |
9299 | ||
9300 | if ((afi == AFI_IP && safi == BGP_SAFI_VPNV6) | |
9301 | || (afi == AFI_IP6 && safi == BGP_SAFI_VPNV4)) | |
9302 | { | |
9303 | vty_out (vty, "%% Invalid subsequent address family %s for %s%s", | |
9304 | afi_str, safi_str, VTY_NEWLINE); | |
9305 | return CMD_WARNING; | |
9306 | } | |
9307 | return bgp_table_stats (vty, bgp, afi, safi); | |
9308 | } | |
9309 | ||
9310 | DEFUN (show_bgp_statistics, | |
9311 | show_bgp_statistics_cmd, | |
9312 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", | |
9313 | SHOW_STR | |
9314 | BGP_STR | |
9315 | "Address family\n" | |
9316 | "Address family\n" | |
9317 | "Address Family modifier\n" | |
9318 | "Address Family modifier\n" | |
9319 | "BGP RIB advertisement statistics\n") | |
9320 | { | |
9321 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9322 | } | |
9323 | ||
9324 | ALIAS (show_bgp_statistics, | |
9325 | show_bgp_statistics_vpnv4_cmd, | |
9326 | "show bgp (ipv4) (vpnv4) statistics", | |
9327 | SHOW_STR | |
9328 | BGP_STR | |
9329 | "Address family\n" | |
9330 | "Address Family modifier\n" | |
9331 | "BGP RIB advertisement statistics\n") | |
9332 | ||
9333 | DEFUN (show_bgp_statistics_view, | |
9334 | show_bgp_statistics_view_cmd, | |
9335 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", | |
9336 | SHOW_STR | |
9337 | BGP_STR | |
9338 | "BGP view\n" | |
9339 | "Address family\n" | |
9340 | "Address family\n" | |
9341 | "Address Family modifier\n" | |
9342 | "Address Family modifier\n" | |
9343 | "BGP RIB advertisement statistics\n") | |
9344 | { | |
9345 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9346 | } | |
9347 | ||
9348 | ALIAS (show_bgp_statistics_view, | |
9349 | show_bgp_statistics_view_vpnv4_cmd, | |
9350 | "show bgp view WORD (ipv4) (vpnv4) statistics", | |
9351 | SHOW_STR | |
9352 | BGP_STR | |
9353 | "BGP view\n" | |
9354 | "Address family\n" | |
9355 | "Address Family modifier\n" | |
9356 | "BGP RIB advertisement statistics\n") | |
9357 | \f | |
ff7924f6 PJ |
9358 | enum bgp_pcounts |
9359 | { | |
9360 | PCOUNT_ADJ_IN = 0, | |
9361 | PCOUNT_DAMPED, | |
9362 | PCOUNT_REMOVED, | |
9363 | PCOUNT_HISTORY, | |
9364 | PCOUNT_STALE, | |
9365 | PCOUNT_VALID, | |
9366 | PCOUNT_ALL, | |
9367 | PCOUNT_COUNTED, | |
9368 | PCOUNT_PFCNT, /* the figure we display to users */ | |
9369 | PCOUNT_MAX, | |
9370 | }; | |
9371 | ||
9372 | static const char *pcount_strs[] = | |
9373 | { | |
9374 | [PCOUNT_ADJ_IN] = "Adj-in", | |
9375 | [PCOUNT_DAMPED] = "Damped", | |
9376 | [PCOUNT_REMOVED] = "Removed", | |
9377 | [PCOUNT_HISTORY] = "History", | |
9378 | [PCOUNT_STALE] = "Stale", | |
9379 | [PCOUNT_VALID] = "Valid", | |
9380 | [PCOUNT_ALL] = "All RIB", | |
9381 | [PCOUNT_COUNTED] = "PfxCt counted", | |
9382 | [PCOUNT_PFCNT] = "Useable", | |
9383 | [PCOUNT_MAX] = NULL, | |
9384 | }; | |
9385 | ||
2815e61f PJ |
9386 | struct peer_pcounts |
9387 | { | |
9388 | unsigned int count[PCOUNT_MAX]; | |
9389 | const struct peer *peer; | |
9390 | const struct bgp_table *table; | |
9391 | }; | |
9392 | ||
ff7924f6 | 9393 | static int |
2815e61f | 9394 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
9395 | { |
9396 | struct bgp_node *rn; | |
2815e61f PJ |
9397 | struct peer_pcounts *pc = THREAD_ARG (t); |
9398 | const struct peer *peer = pc->peer; | |
ff7924f6 | 9399 | |
2815e61f | 9400 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
9401 | { |
9402 | struct bgp_adj_in *ain; | |
2815e61f | 9403 | struct bgp_info *ri; |
ff7924f6 PJ |
9404 | |
9405 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9406 | if (ain->peer == peer) | |
2815e61f | 9407 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 9408 | |
ff7924f6 PJ |
9409 | for (ri = rn->info; ri; ri = ri->next) |
9410 | { | |
9411 | char buf[SU_ADDRSTRLEN]; | |
9412 | ||
9413 | if (ri->peer != peer) | |
9414 | continue; | |
9415 | ||
2815e61f | 9416 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
9417 | |
9418 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 9419 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 9420 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 9421 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 9422 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 9423 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 9424 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 9425 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 9426 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 9427 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 9428 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 9429 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
9430 | |
9431 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
9432 | { | |
2815e61f | 9433 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 9434 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9435 | plog_warn (peer->log, |
9436 | "%s [pcount] %s/%d is counted but flags 0x%x", | |
9437 | peer->host, | |
9438 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9439 | buf, SU_ADDRSTRLEN), | |
9440 | rn->p.prefixlen, | |
9441 | ri->flags); | |
9442 | } | |
9443 | else | |
9444 | { | |
1a392d46 | 9445 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9446 | plog_warn (peer->log, |
9447 | "%s [pcount] %s/%d not counted but flags 0x%x", | |
9448 | peer->host, | |
9449 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9450 | buf, SU_ADDRSTRLEN), | |
9451 | rn->p.prefixlen, | |
9452 | ri->flags); | |
9453 | } | |
9454 | } | |
9455 | } | |
2815e61f PJ |
9456 | return 0; |
9457 | } | |
ff7924f6 | 9458 | |
2815e61f PJ |
9459 | static int |
9460 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) | |
9461 | { | |
9462 | struct peer_pcounts pcounts = { .peer = peer }; | |
9463 | unsigned int i; | |
9464 | ||
9465 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
9466 | || !peer->bgp->rib[afi][safi]) | |
9467 | { | |
9468 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9469 | return CMD_WARNING; | |
9470 | } | |
9471 | ||
9472 | memset (&pcounts, 0, sizeof(pcounts)); | |
9473 | pcounts.peer = peer; | |
9474 | pcounts.table = peer->bgp->rib[afi][safi]; | |
9475 | ||
9476 | /* in-place call via thread subsystem so as to record execution time | |
9477 | * stats for the thread-walk (i.e. ensure this can't be blamed on | |
9478 | * on just vty_read()). | |
9479 | */ | |
9480 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); | |
9481 | ||
ff7924f6 PJ |
9482 | vty_out (vty, "Prefix counts for %s, %s%s", |
9483 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
9484 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); | |
9485 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
9486 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
9487 | ||
9488 | for (i = 0; i < PCOUNT_MAX; i++) | |
2815e61f PJ |
9489 | vty_out (vty, "%20s: %-10d%s", |
9490 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
ff7924f6 | 9491 | |
2815e61f | 9492 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
ff7924f6 PJ |
9493 | { |
9494 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
9495 | peer->host, VTY_NEWLINE); | |
9496 | vty_out (vty, "Please report this bug, with the above command output%s", | |
9497 | VTY_NEWLINE); | |
9498 | } | |
9499 | ||
9500 | return CMD_SUCCESS; | |
9501 | } | |
9502 | ||
9503 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
9504 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
9505 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9506 | SHOW_STR | |
9507 | IP_STR | |
9508 | BGP_STR | |
9509 | "Detailed information on TCP and BGP neighbor connections\n" | |
9510 | "Neighbor to display information about\n" | |
9511 | "Neighbor to display information about\n" | |
9512 | "Display detailed prefix count information\n") | |
9513 | { | |
9514 | struct peer *peer; | |
9515 | ||
9516 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9517 | if (! peer) | |
9518 | return CMD_WARNING; | |
9519 | ||
9520 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9521 | } | |
9522 | ||
9523 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, | |
9524 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
9525 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9526 | SHOW_STR | |
9527 | BGP_STR | |
9528 | "Address family\n" | |
9529 | "Detailed information on TCP and BGP neighbor connections\n" | |
9530 | "Neighbor to display information about\n" | |
9531 | "Neighbor to display information about\n" | |
9532 | "Display detailed prefix count information\n") | |
9533 | { | |
9534 | struct peer *peer; | |
9535 | ||
9536 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9537 | if (! peer) | |
9538 | return CMD_WARNING; | |
9539 | ||
9540 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); | |
9541 | } | |
9542 | ||
9543 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, | |
9544 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
9545 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9546 | SHOW_STR | |
9547 | IP_STR | |
9548 | BGP_STR | |
9549 | "Address family\n" | |
9550 | "Address Family modifier\n" | |
9551 | "Address Family modifier\n" | |
9552 | "Detailed information on TCP and BGP neighbor connections\n" | |
9553 | "Neighbor to display information about\n" | |
9554 | "Neighbor to display information about\n" | |
9555 | "Display detailed prefix count information\n") | |
9556 | { | |
9557 | struct peer *peer; | |
9558 | ||
9559 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9560 | if (! peer) | |
9561 | return CMD_WARNING; | |
9562 | ||
9563 | if (strncmp (argv[0], "m", 1) == 0) | |
9564 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); | |
9565 | ||
9566 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9567 | } | |
9568 | ||
9569 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
9570 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
9571 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9572 | SHOW_STR | |
9573 | IP_STR | |
9574 | BGP_STR | |
9575 | "Address family\n" | |
9576 | "Address Family modifier\n" | |
9577 | "Address Family modifier\n" | |
9578 | "Detailed information on TCP and BGP neighbor connections\n" | |
9579 | "Neighbor to display information about\n" | |
9580 | "Neighbor to display information about\n" | |
9581 | "Display detailed prefix count information\n") | |
9582 | { | |
9583 | struct peer *peer; | |
9584 | ||
9585 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9586 | if (! peer) | |
9587 | return CMD_WARNING; | |
9588 | ||
9589 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); | |
9590 | } | |
9591 | ||
9592 | ||
94f2b392 | 9593 | static void |
718e3744 | 9594 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
9595 | int in) | |
9596 | { | |
9597 | struct bgp_table *table; | |
9598 | struct bgp_adj_in *ain; | |
9599 | struct bgp_adj_out *adj; | |
9600 | unsigned long output_count; | |
9601 | struct bgp_node *rn; | |
9602 | int header1 = 1; | |
9603 | struct bgp *bgp; | |
9604 | int header2 = 1; | |
9605 | ||
bb46e94f | 9606 | bgp = peer->bgp; |
718e3744 | 9607 | |
9608 | if (! bgp) | |
9609 | return; | |
9610 | ||
9611 | table = bgp->rib[afi][safi]; | |
9612 | ||
9613 | output_count = 0; | |
9614 | ||
9615 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], | |
9616 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
9617 | { | |
9618 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9619 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9620 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9621 | |
9622 | vty_out (vty, "Originating default network 0.0.0.0%s%s", | |
9623 | VTY_NEWLINE, VTY_NEWLINE); | |
9624 | header1 = 0; | |
9625 | } | |
9626 | ||
9627 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
9628 | if (in) | |
9629 | { | |
9630 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9631 | if (ain->peer == peer) | |
9632 | { | |
9633 | if (header1) | |
9634 | { | |
9635 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9636 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9637 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9638 | header1 = 0; |
9639 | } | |
9640 | if (header2) | |
9641 | { | |
9642 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9643 | header2 = 0; | |
9644 | } | |
9645 | if (ain->attr) | |
9646 | { | |
9647 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); | |
9648 | output_count++; | |
9649 | } | |
9650 | } | |
9651 | } | |
9652 | else | |
9653 | { | |
9654 | for (adj = rn->adj_out; adj; adj = adj->next) | |
9655 | if (adj->peer == peer) | |
9656 | { | |
9657 | if (header1) | |
9658 | { | |
9659 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9660 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9661 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9662 | header1 = 0; |
9663 | } | |
9664 | if (header2) | |
9665 | { | |
9666 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9667 | header2 = 0; | |
9668 | } | |
9669 | if (adj->attr) | |
9670 | { | |
9671 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); | |
9672 | output_count++; | |
9673 | } | |
9674 | } | |
9675 | } | |
9676 | ||
9677 | if (output_count != 0) | |
9678 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
9679 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
9680 | } | |
9681 | ||
94f2b392 | 9682 | static int |
bb46e94f | 9683 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
9684 | { | |
718e3744 | 9685 | if (! peer || ! peer->afc[afi][safi]) |
9686 | { | |
9687 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9688 | return CMD_WARNING; | |
9689 | } | |
9690 | ||
9691 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9692 | { | |
9693 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", | |
9694 | VTY_NEWLINE); | |
9695 | return CMD_WARNING; | |
9696 | } | |
9697 | ||
9698 | show_adj_route (vty, peer, afi, safi, in); | |
9699 | ||
9700 | return CMD_SUCCESS; | |
9701 | } | |
9702 | ||
2a71e9ce TP |
9703 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
9704 | show_ip_bgp_view_neighbor_advertised_route_cmd, | |
9705 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9706 | SHOW_STR |
9707 | IP_STR | |
9708 | BGP_STR | |
2a71e9ce TP |
9709 | "BGP view\n" |
9710 | "View name\n" | |
718e3744 | 9711 | "Detailed information on TCP and BGP neighbor connections\n" |
9712 | "Neighbor to display information about\n" | |
9713 | "Neighbor to display information about\n" | |
9714 | "Display the routes advertised to a BGP neighbor\n") | |
9715 | { | |
bb46e94f | 9716 | struct peer *peer; |
9717 | ||
2a71e9ce TP |
9718 | if (argc == 2) |
9719 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9720 | else | |
9721 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9722 | ||
bb46e94f | 9723 | if (! peer) |
9724 | return CMD_WARNING; | |
9725 | ||
9726 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); | |
718e3744 | 9727 | } |
9728 | ||
2a71e9ce TP |
9729 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
9730 | show_ip_bgp_neighbor_advertised_route_cmd, | |
9731 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9732 | SHOW_STR | |
9733 | IP_STR | |
9734 | BGP_STR | |
9735 | "Detailed information on TCP and BGP neighbor connections\n" | |
9736 | "Neighbor to display information about\n" | |
9737 | "Neighbor to display information about\n" | |
9738 | "Display the routes advertised to a BGP neighbor\n") | |
9739 | ||
718e3744 | 9740 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
9741 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
9742 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9743 | SHOW_STR | |
9744 | IP_STR | |
9745 | BGP_STR | |
9746 | "Address family\n" | |
9747 | "Address Family modifier\n" | |
9748 | "Address Family modifier\n" | |
9749 | "Detailed information on TCP and BGP neighbor connections\n" | |
9750 | "Neighbor to display information about\n" | |
9751 | "Neighbor to display information about\n" | |
9752 | "Display the routes advertised to a BGP neighbor\n") | |
9753 | { | |
bb46e94f | 9754 | struct peer *peer; |
9755 | ||
9756 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9757 | if (! peer) | |
9758 | return CMD_WARNING; | |
9759 | ||
718e3744 | 9760 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9761 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
718e3744 | 9762 | |
bb46e94f | 9763 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
718e3744 | 9764 | } |
9765 | ||
9766 | #ifdef HAVE_IPV6 | |
bb46e94f | 9767 | DEFUN (show_bgp_view_neighbor_advertised_route, |
9768 | show_bgp_view_neighbor_advertised_route_cmd, | |
9769 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9770 | SHOW_STR |
9771 | BGP_STR | |
bb46e94f | 9772 | "BGP view\n" |
9773 | "View name\n" | |
718e3744 | 9774 | "Detailed information on TCP and BGP neighbor connections\n" |
9775 | "Neighbor to display information about\n" | |
9776 | "Neighbor to display information about\n" | |
9777 | "Display the routes advertised to a BGP neighbor\n") | |
9778 | { | |
bb46e94f | 9779 | struct peer *peer; |
9780 | ||
9781 | if (argc == 2) | |
9782 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9783 | else | |
9784 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9785 | ||
9786 | if (! peer) | |
9787 | return CMD_WARNING; | |
9788 | ||
9789 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); | |
9790 | } | |
9791 | ||
9792 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9793 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, | |
9794 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9795 | SHOW_STR | |
9796 | BGP_STR | |
9797 | "BGP view\n" | |
9798 | "View name\n" | |
9799 | "Address family\n" | |
9800 | "Detailed information on TCP and BGP neighbor connections\n" | |
9801 | "Neighbor to display information about\n" | |
9802 | "Neighbor to display information about\n" | |
9803 | "Display the routes advertised to a BGP neighbor\n") | |
9804 | ||
9805 | DEFUN (show_bgp_view_neighbor_received_routes, | |
9806 | show_bgp_view_neighbor_received_routes_cmd, | |
9807 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9808 | SHOW_STR | |
9809 | BGP_STR | |
9810 | "BGP view\n" | |
9811 | "View name\n" | |
9812 | "Detailed information on TCP and BGP neighbor connections\n" | |
9813 | "Neighbor to display information about\n" | |
9814 | "Neighbor to display information about\n" | |
9815 | "Display the received routes from neighbor\n") | |
9816 | { | |
9817 | struct peer *peer; | |
9818 | ||
9819 | if (argc == 2) | |
9820 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9821 | else | |
9822 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9823 | ||
9824 | if (! peer) | |
9825 | return CMD_WARNING; | |
9826 | ||
9827 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); | |
718e3744 | 9828 | } |
9829 | ||
bb46e94f | 9830 | ALIAS (show_bgp_view_neighbor_received_routes, |
9831 | show_bgp_view_ipv6_neighbor_received_routes_cmd, | |
9832 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9833 | SHOW_STR | |
9834 | BGP_STR | |
9835 | "BGP view\n" | |
9836 | "View name\n" | |
9837 | "Address family\n" | |
9838 | "Detailed information on TCP and BGP neighbor connections\n" | |
9839 | "Neighbor to display information about\n" | |
9840 | "Neighbor to display information about\n" | |
9841 | "Display the received routes from neighbor\n") | |
9842 | ||
9843 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9844 | show_bgp_neighbor_advertised_route_cmd, | |
9845 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9846 | SHOW_STR | |
9847 | BGP_STR | |
9848 | "Detailed information on TCP and BGP neighbor connections\n" | |
9849 | "Neighbor to display information about\n" | |
9850 | "Neighbor to display information about\n" | |
9851 | "Display the routes advertised to a BGP neighbor\n") | |
9852 | ||
9853 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
718e3744 | 9854 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
9855 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9856 | SHOW_STR | |
9857 | BGP_STR | |
9858 | "Address family\n" | |
9859 | "Detailed information on TCP and BGP neighbor connections\n" | |
9860 | "Neighbor to display information about\n" | |
9861 | "Neighbor to display information about\n" | |
9862 | "Display the routes advertised to a BGP neighbor\n") | |
9863 | ||
9864 | /* old command */ | |
bb46e94f | 9865 | ALIAS (show_bgp_view_neighbor_advertised_route, |
718e3744 | 9866 | ipv6_bgp_neighbor_advertised_route_cmd, |
9867 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9868 | SHOW_STR | |
9869 | IPV6_STR | |
9870 | BGP_STR | |
9871 | "Detailed information on TCP and BGP neighbor connections\n" | |
9872 | "Neighbor to display information about\n" | |
9873 | "Neighbor to display information about\n" | |
9874 | "Display the routes advertised to a BGP neighbor\n") | |
bb46e94f | 9875 | |
718e3744 | 9876 | /* old command */ |
9877 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
9878 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
9879 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9880 | SHOW_STR | |
9881 | IPV6_STR | |
9882 | MBGP_STR | |
9883 | "Detailed information on TCP and BGP neighbor connections\n" | |
9884 | "Neighbor to display information about\n" | |
9885 | "Neighbor to display information about\n" | |
9886 | "Display the routes advertised to a BGP neighbor\n") | |
9887 | { | |
bb46e94f | 9888 | struct peer *peer; |
9889 | ||
9890 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9891 | if (! peer) | |
9892 | return CMD_WARNING; | |
9893 | ||
9894 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); | |
718e3744 | 9895 | } |
9896 | #endif /* HAVE_IPV6 */ | |
9897 | \f | |
2a71e9ce TP |
9898 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
9899 | show_ip_bgp_view_neighbor_received_routes_cmd, | |
9900 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
718e3744 | 9901 | SHOW_STR |
9902 | IP_STR | |
9903 | BGP_STR | |
2a71e9ce TP |
9904 | "BGP view\n" |
9905 | "View name\n" | |
718e3744 | 9906 | "Detailed information on TCP and BGP neighbor connections\n" |
9907 | "Neighbor to display information about\n" | |
9908 | "Neighbor to display information about\n" | |
9909 | "Display the received routes from neighbor\n") | |
9910 | { | |
bb46e94f | 9911 | struct peer *peer; |
9912 | ||
2a71e9ce TP |
9913 | if (argc == 2) |
9914 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9915 | else | |
9916 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9917 | ||
bb46e94f | 9918 | if (! peer) |
9919 | return CMD_WARNING; | |
9920 | ||
9921 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); | |
718e3744 | 9922 | } |
9923 | ||
2a71e9ce TP |
9924 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
9925 | show_ip_bgp_neighbor_received_routes_cmd, | |
9926 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9927 | SHOW_STR | |
9928 | IP_STR | |
9929 | BGP_STR | |
9930 | "Detailed information on TCP and BGP neighbor connections\n" | |
9931 | "Neighbor to display information about\n" | |
9932 | "Neighbor to display information about\n" | |
9933 | "Display the received routes from neighbor\n") | |
9934 | ||
718e3744 | 9935 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
9936 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
9937 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9938 | SHOW_STR | |
9939 | IP_STR | |
9940 | BGP_STR | |
9941 | "Address family\n" | |
9942 | "Address Family modifier\n" | |
9943 | "Address Family modifier\n" | |
9944 | "Detailed information on TCP and BGP neighbor connections\n" | |
9945 | "Neighbor to display information about\n" | |
9946 | "Neighbor to display information about\n" | |
9947 | "Display the received routes from neighbor\n") | |
9948 | { | |
bb46e94f | 9949 | struct peer *peer; |
9950 | ||
9951 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9952 | if (! peer) | |
9953 | return CMD_WARNING; | |
9954 | ||
718e3744 | 9955 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9956 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
718e3744 | 9957 | |
bb46e94f | 9958 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
718e3744 | 9959 | } |
9960 | ||
9961 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, | |
9962 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
9963 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
9964 | SHOW_STR | |
9965 | IP_STR | |
9966 | BGP_STR | |
9967 | "Detailed information on TCP and BGP neighbor connections\n" | |
9968 | "Neighbor to display information about\n" | |
9969 | "Neighbor to display information about\n" | |
9970 | "Display information received from a BGP neighbor\n" | |
9971 | "Display the prefixlist filter\n") | |
9972 | { | |
9973 | char name[BUFSIZ]; | |
9974 | union sockunion *su; | |
9975 | struct peer *peer; | |
9976 | int count; | |
9977 | ||
9978 | su = sockunion_str2su (argv[0]); | |
9979 | if (su == NULL) | |
9980 | return CMD_WARNING; | |
9981 | ||
9982 | peer = peer_lookup (NULL, su); | |
9983 | if (! peer) | |
9984 | return CMD_WARNING; | |
9985 | ||
9986 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
9987 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
9988 | if (count) | |
9989 | { | |
9990 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
9991 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
9992 | } | |
9993 | ||
9994 | return CMD_SUCCESS; | |
9995 | } | |
9996 | ||
9997 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
9998 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
9999 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10000 | SHOW_STR | |
10001 | IP_STR | |
10002 | BGP_STR | |
10003 | "Address family\n" | |
10004 | "Address Family modifier\n" | |
10005 | "Address Family modifier\n" | |
10006 | "Detailed information on TCP and BGP neighbor connections\n" | |
10007 | "Neighbor to display information about\n" | |
10008 | "Neighbor to display information about\n" | |
10009 | "Display information received from a BGP neighbor\n" | |
10010 | "Display the prefixlist filter\n") | |
10011 | { | |
10012 | char name[BUFSIZ]; | |
10013 | union sockunion *su; | |
10014 | struct peer *peer; | |
10015 | int count; | |
10016 | ||
10017 | su = sockunion_str2su (argv[1]); | |
10018 | if (su == NULL) | |
10019 | return CMD_WARNING; | |
10020 | ||
10021 | peer = peer_lookup (NULL, su); | |
10022 | if (! peer) | |
10023 | return CMD_WARNING; | |
10024 | ||
10025 | if (strncmp (argv[0], "m", 1) == 0) | |
10026 | { | |
10027 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
10028 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10029 | if (count) | |
10030 | { | |
10031 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); | |
10032 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10033 | } | |
10034 | } | |
10035 | else | |
10036 | { | |
10037 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10038 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10039 | if (count) | |
10040 | { | |
10041 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10042 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10043 | } | |
10044 | } | |
10045 | ||
10046 | return CMD_SUCCESS; | |
10047 | } | |
10048 | ||
10049 | ||
10050 | #ifdef HAVE_IPV6 | |
bb46e94f | 10051 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10052 | show_bgp_neighbor_received_routes_cmd, |
10053 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10054 | SHOW_STR | |
10055 | BGP_STR | |
10056 | "Detailed information on TCP and BGP neighbor connections\n" | |
10057 | "Neighbor to display information about\n" | |
10058 | "Neighbor to display information about\n" | |
10059 | "Display the received routes from neighbor\n") | |
718e3744 | 10060 | |
bb46e94f | 10061 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10062 | show_bgp_ipv6_neighbor_received_routes_cmd, |
10063 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10064 | SHOW_STR | |
10065 | BGP_STR | |
10066 | "Address family\n" | |
10067 | "Detailed information on TCP and BGP neighbor connections\n" | |
10068 | "Neighbor to display information about\n" | |
10069 | "Neighbor to display information about\n" | |
10070 | "Display the received routes from neighbor\n") | |
10071 | ||
10072 | DEFUN (show_bgp_neighbor_received_prefix_filter, | |
10073 | show_bgp_neighbor_received_prefix_filter_cmd, | |
10074 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10075 | SHOW_STR | |
10076 | BGP_STR | |
10077 | "Detailed information on TCP and BGP neighbor connections\n" | |
10078 | "Neighbor to display information about\n" | |
10079 | "Neighbor to display information about\n" | |
10080 | "Display information received from a BGP neighbor\n" | |
10081 | "Display the prefixlist filter\n") | |
10082 | { | |
10083 | char name[BUFSIZ]; | |
10084 | union sockunion *su; | |
10085 | struct peer *peer; | |
10086 | int count; | |
10087 | ||
10088 | su = sockunion_str2su (argv[0]); | |
10089 | if (su == NULL) | |
10090 | return CMD_WARNING; | |
10091 | ||
10092 | peer = peer_lookup (NULL, su); | |
10093 | if (! peer) | |
10094 | return CMD_WARNING; | |
10095 | ||
10096 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10097 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10098 | if (count) | |
10099 | { | |
10100 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10101 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10102 | } | |
10103 | ||
10104 | return CMD_SUCCESS; | |
10105 | } | |
10106 | ||
10107 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
10108 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
10109 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10110 | SHOW_STR | |
10111 | BGP_STR | |
10112 | "Address family\n" | |
10113 | "Detailed information on TCP and BGP neighbor connections\n" | |
10114 | "Neighbor to display information about\n" | |
10115 | "Neighbor to display information about\n" | |
10116 | "Display information received from a BGP neighbor\n" | |
10117 | "Display the prefixlist filter\n") | |
10118 | ||
10119 | /* old command */ | |
bb46e94f | 10120 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10121 | ipv6_bgp_neighbor_received_routes_cmd, |
10122 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10123 | SHOW_STR | |
10124 | IPV6_STR | |
10125 | BGP_STR | |
10126 | "Detailed information on TCP and BGP neighbor connections\n" | |
10127 | "Neighbor to display information about\n" | |
10128 | "Neighbor to display information about\n" | |
10129 | "Display the received routes from neighbor\n") | |
718e3744 | 10130 | |
10131 | /* old command */ | |
10132 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
10133 | ipv6_mbgp_neighbor_received_routes_cmd, | |
10134 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10135 | SHOW_STR | |
10136 | IPV6_STR | |
10137 | MBGP_STR | |
10138 | "Detailed information on TCP and BGP neighbor connections\n" | |
10139 | "Neighbor to display information about\n" | |
10140 | "Neighbor to display information about\n" | |
10141 | "Display the received routes from neighbor\n") | |
10142 | { | |
bb46e94f | 10143 | struct peer *peer; |
10144 | ||
10145 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10146 | if (! peer) | |
10147 | return CMD_WARNING; | |
10148 | ||
10149 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); | |
10150 | } | |
10151 | ||
10152 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, | |
10153 | show_bgp_view_neighbor_received_prefix_filter_cmd, | |
10154 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10155 | SHOW_STR | |
10156 | BGP_STR | |
10157 | "BGP view\n" | |
10158 | "View name\n" | |
10159 | "Detailed information on TCP and BGP neighbor connections\n" | |
10160 | "Neighbor to display information about\n" | |
10161 | "Neighbor to display information about\n" | |
10162 | "Display information received from a BGP neighbor\n" | |
10163 | "Display the prefixlist filter\n") | |
10164 | { | |
10165 | char name[BUFSIZ]; | |
10166 | union sockunion *su; | |
10167 | struct peer *peer; | |
10168 | struct bgp *bgp; | |
10169 | int count; | |
10170 | ||
10171 | /* BGP structure lookup. */ | |
10172 | bgp = bgp_lookup_by_name (argv[0]); | |
10173 | if (bgp == NULL) | |
10174 | { | |
10175 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10176 | return CMD_WARNING; | |
10177 | } | |
10178 | ||
10179 | su = sockunion_str2su (argv[1]); | |
10180 | if (su == NULL) | |
10181 | return CMD_WARNING; | |
10182 | ||
10183 | peer = peer_lookup (bgp, su); | |
10184 | if (! peer) | |
10185 | return CMD_WARNING; | |
10186 | ||
10187 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10188 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10189 | if (count) | |
10190 | { | |
10191 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10192 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10193 | } | |
10194 | ||
10195 | return CMD_SUCCESS; | |
718e3744 | 10196 | } |
bb46e94f | 10197 | |
10198 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, | |
10199 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, | |
10200 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10201 | SHOW_STR | |
10202 | BGP_STR | |
10203 | "BGP view\n" | |
10204 | "View name\n" | |
10205 | "Address family\n" | |
10206 | "Detailed information on TCP and BGP neighbor connections\n" | |
10207 | "Neighbor to display information about\n" | |
10208 | "Neighbor to display information about\n" | |
10209 | "Display information received from a BGP neighbor\n" | |
10210 | "Display the prefixlist filter\n") | |
718e3744 | 10211 | #endif /* HAVE_IPV6 */ |
10212 | \f | |
94f2b392 | 10213 | static int |
bb46e94f | 10214 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
718e3744 | 10215 | safi_t safi, enum bgp_show_type type) |
10216 | { | |
718e3744 | 10217 | if (! peer || ! peer->afc[afi][safi]) |
10218 | { | |
10219 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 10220 | return CMD_WARNING; |
10221 | } | |
10222 | ||
5a646650 | 10223 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
718e3744 | 10224 | } |
10225 | ||
10226 | DEFUN (show_ip_bgp_neighbor_routes, | |
10227 | show_ip_bgp_neighbor_routes_cmd, | |
10228 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10229 | SHOW_STR | |
10230 | IP_STR | |
10231 | BGP_STR | |
10232 | "Detailed information on TCP and BGP neighbor connections\n" | |
10233 | "Neighbor to display information about\n" | |
10234 | "Neighbor to display information about\n" | |
10235 | "Display routes learned from neighbor\n") | |
10236 | { | |
bb46e94f | 10237 | struct peer *peer; |
10238 | ||
10239 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10240 | if (! peer) | |
10241 | return CMD_WARNING; | |
10242 | ||
10243 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10244 | bgp_show_type_neighbor); |
10245 | } | |
10246 | ||
10247 | DEFUN (show_ip_bgp_neighbor_flap, | |
10248 | show_ip_bgp_neighbor_flap_cmd, | |
10249 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10250 | SHOW_STR | |
10251 | IP_STR | |
10252 | BGP_STR | |
10253 | "Detailed information on TCP and BGP neighbor connections\n" | |
10254 | "Neighbor to display information about\n" | |
10255 | "Neighbor to display information about\n" | |
10256 | "Display flap statistics of the routes learned from neighbor\n") | |
10257 | { | |
bb46e94f | 10258 | struct peer *peer; |
10259 | ||
10260 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10261 | if (! peer) | |
10262 | return CMD_WARNING; | |
10263 | ||
10264 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10265 | bgp_show_type_flap_neighbor); |
10266 | } | |
10267 | ||
10268 | DEFUN (show_ip_bgp_neighbor_damp, | |
10269 | show_ip_bgp_neighbor_damp_cmd, | |
10270 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10271 | SHOW_STR | |
10272 | IP_STR | |
10273 | BGP_STR | |
10274 | "Detailed information on TCP and BGP neighbor connections\n" | |
10275 | "Neighbor to display information about\n" | |
10276 | "Neighbor to display information about\n" | |
10277 | "Display the dampened routes received from neighbor\n") | |
10278 | { | |
bb46e94f | 10279 | struct peer *peer; |
10280 | ||
10281 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10282 | if (! peer) | |
10283 | return CMD_WARNING; | |
10284 | ||
10285 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10286 | bgp_show_type_damp_neighbor); |
10287 | } | |
10288 | ||
10289 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
10290 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
10291 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", | |
10292 | SHOW_STR | |
10293 | IP_STR | |
10294 | BGP_STR | |
10295 | "Address family\n" | |
10296 | "Address Family modifier\n" | |
10297 | "Address Family modifier\n" | |
10298 | "Detailed information on TCP and BGP neighbor connections\n" | |
10299 | "Neighbor to display information about\n" | |
10300 | "Neighbor to display information about\n" | |
10301 | "Display routes learned from neighbor\n") | |
10302 | { | |
bb46e94f | 10303 | struct peer *peer; |
10304 | ||
10305 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10306 | if (! peer) | |
10307 | return CMD_WARNING; | |
10308 | ||
718e3744 | 10309 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10310 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
718e3744 | 10311 | bgp_show_type_neighbor); |
10312 | ||
bb46e94f | 10313 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
718e3744 | 10314 | bgp_show_type_neighbor); |
10315 | } | |
bb46e94f | 10316 | |
fee0f4c6 | 10317 | DEFUN (show_ip_bgp_view_rsclient, |
10318 | show_ip_bgp_view_rsclient_cmd, | |
10319 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10320 | SHOW_STR | |
10321 | IP_STR | |
10322 | BGP_STR | |
10323 | "BGP view\n" | |
10324 | "BGP view name\n" | |
10325 | "Information about Route Server Client\n" | |
10326 | NEIGHBOR_ADDR_STR) | |
10327 | { | |
10328 | struct bgp_table *table; | |
10329 | struct peer *peer; | |
10330 | ||
10331 | if (argc == 2) | |
10332 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10333 | else | |
10334 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10335 | ||
10336 | if (! peer) | |
10337 | return CMD_WARNING; | |
10338 | ||
10339 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10340 | { | |
10341 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10342 | VTY_NEWLINE); | |
10343 | return CMD_WARNING; | |
10344 | } | |
10345 | ||
10346 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10347 | PEER_FLAG_RSERVER_CLIENT)) | |
10348 | { | |
10349 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10350 | VTY_NEWLINE); | |
10351 | return CMD_WARNING; | |
10352 | } | |
10353 | ||
10354 | table = peer->rib[AFI_IP][SAFI_UNICAST]; | |
10355 | ||
5a646650 | 10356 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10357 | } |
10358 | ||
10359 | ALIAS (show_ip_bgp_view_rsclient, | |
10360 | show_ip_bgp_rsclient_cmd, | |
10361 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", | |
10362 | SHOW_STR | |
10363 | IP_STR | |
10364 | BGP_STR | |
10365 | "Information about Route Server Client\n" | |
10366 | NEIGHBOR_ADDR_STR) | |
10367 | ||
10368 | DEFUN (show_ip_bgp_view_rsclient_route, | |
10369 | show_ip_bgp_view_rsclient_route_cmd, | |
a8bf6f52 | 10370 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
fee0f4c6 | 10371 | SHOW_STR |
10372 | IP_STR | |
10373 | BGP_STR | |
10374 | "BGP view\n" | |
10375 | "BGP view name\n" | |
10376 | "Information about Route Server Client\n" | |
10377 | NEIGHBOR_ADDR_STR | |
10378 | "Network in the BGP routing table to display\n") | |
10379 | { | |
10380 | struct bgp *bgp; | |
10381 | struct peer *peer; | |
10382 | ||
10383 | /* BGP structure lookup. */ | |
10384 | if (argc == 3) | |
10385 | { | |
10386 | bgp = bgp_lookup_by_name (argv[0]); | |
10387 | if (bgp == NULL) | |
10388 | { | |
10389 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10390 | return CMD_WARNING; | |
10391 | } | |
10392 | } | |
10393 | else | |
10394 | { | |
10395 | bgp = bgp_get_default (); | |
10396 | if (bgp == NULL) | |
10397 | { | |
10398 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10399 | return CMD_WARNING; | |
10400 | } | |
10401 | } | |
10402 | ||
10403 | if (argc == 3) | |
10404 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10405 | else | |
10406 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10407 | ||
10408 | if (! peer) | |
10409 | return CMD_WARNING; | |
10410 | ||
10411 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10412 | { | |
10413 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10414 | VTY_NEWLINE); | |
10415 | return CMD_WARNING; | |
10416 | } | |
10417 | ||
10418 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10419 | PEER_FLAG_RSERVER_CLIENT)) | |
10420 | { | |
10421 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10422 | VTY_NEWLINE); | |
10423 | return CMD_WARNING; | |
10424 | } | |
10425 | ||
10426 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10427 | (argc == 3) ? argv[2] : argv[1], | |
10428 | AFI_IP, SAFI_UNICAST, NULL, 0); | |
10429 | } | |
10430 | ||
10431 | ALIAS (show_ip_bgp_view_rsclient_route, | |
10432 | show_ip_bgp_rsclient_route_cmd, | |
10433 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10434 | SHOW_STR | |
10435 | IP_STR | |
10436 | BGP_STR | |
10437 | "Information about Route Server Client\n" | |
10438 | NEIGHBOR_ADDR_STR | |
10439 | "Network in the BGP routing table to display\n") | |
10440 | ||
10441 | DEFUN (show_ip_bgp_view_rsclient_prefix, | |
10442 | show_ip_bgp_view_rsclient_prefix_cmd, | |
10443 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10444 | SHOW_STR | |
10445 | IP_STR | |
10446 | BGP_STR | |
10447 | "BGP view\n" | |
10448 | "BGP view name\n" | |
10449 | "Information about Route Server Client\n" | |
10450 | NEIGHBOR_ADDR_STR | |
10451 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10452 | { | |
10453 | struct bgp *bgp; | |
10454 | struct peer *peer; | |
10455 | ||
10456 | /* BGP structure lookup. */ | |
10457 | if (argc == 3) | |
10458 | { | |
10459 | bgp = bgp_lookup_by_name (argv[0]); | |
10460 | if (bgp == NULL) | |
10461 | { | |
10462 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10463 | return CMD_WARNING; | |
10464 | } | |
10465 | } | |
10466 | else | |
10467 | { | |
10468 | bgp = bgp_get_default (); | |
10469 | if (bgp == NULL) | |
10470 | { | |
10471 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10472 | return CMD_WARNING; | |
10473 | } | |
10474 | } | |
10475 | ||
10476 | if (argc == 3) | |
10477 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10478 | else | |
10479 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10480 | ||
10481 | if (! peer) | |
10482 | return CMD_WARNING; | |
10483 | ||
10484 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10485 | { | |
10486 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10487 | VTY_NEWLINE); | |
10488 | return CMD_WARNING; | |
10489 | } | |
10490 | ||
10491 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10492 | PEER_FLAG_RSERVER_CLIENT)) | |
10493 | { | |
10494 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10495 | VTY_NEWLINE); | |
10496 | return CMD_WARNING; | |
10497 | } | |
10498 | ||
10499 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10500 | (argc == 3) ? argv[2] : argv[1], | |
10501 | AFI_IP, SAFI_UNICAST, NULL, 1); | |
10502 | } | |
10503 | ||
10504 | ALIAS (show_ip_bgp_view_rsclient_prefix, | |
10505 | show_ip_bgp_rsclient_prefix_cmd, | |
10506 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10507 | SHOW_STR | |
10508 | IP_STR | |
10509 | BGP_STR | |
10510 | "Information about Route Server Client\n" | |
10511 | NEIGHBOR_ADDR_STR | |
10512 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10513 | ||
10514 | ||
718e3744 | 10515 | #ifdef HAVE_IPV6 |
bb46e94f | 10516 | DEFUN (show_bgp_view_neighbor_routes, |
10517 | show_bgp_view_neighbor_routes_cmd, | |
10518 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", | |
718e3744 | 10519 | SHOW_STR |
10520 | BGP_STR | |
bb46e94f | 10521 | "BGP view\n" |
10522 | "BGP view name\n" | |
718e3744 | 10523 | "Detailed information on TCP and BGP neighbor connections\n" |
10524 | "Neighbor to display information about\n" | |
10525 | "Neighbor to display information about\n" | |
10526 | "Display routes learned from neighbor\n") | |
10527 | { | |
bb46e94f | 10528 | struct peer *peer; |
10529 | ||
10530 | if (argc == 2) | |
10531 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10532 | else | |
10533 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10534 | ||
10535 | if (! peer) | |
10536 | return CMD_WARNING; | |
10537 | ||
10538 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
718e3744 | 10539 | bgp_show_type_neighbor); |
10540 | } | |
10541 | ||
bb46e94f | 10542 | ALIAS (show_bgp_view_neighbor_routes, |
10543 | show_bgp_view_ipv6_neighbor_routes_cmd, | |
10544 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
10545 | SHOW_STR | |
10546 | BGP_STR | |
10547 | "BGP view\n" | |
10548 | "BGP view name\n" | |
10549 | "Address family\n" | |
10550 | "Detailed information on TCP and BGP neighbor connections\n" | |
10551 | "Neighbor to display information about\n" | |
10552 | "Neighbor to display information about\n" | |
10553 | "Display routes learned from neighbor\n") | |
10554 | ||
10555 | DEFUN (show_bgp_view_neighbor_damp, | |
10556 | show_bgp_view_neighbor_damp_cmd, | |
10557 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10558 | SHOW_STR | |
10559 | BGP_STR | |
10560 | "BGP view\n" | |
10561 | "BGP view name\n" | |
10562 | "Detailed information on TCP and BGP neighbor connections\n" | |
10563 | "Neighbor to display information about\n" | |
10564 | "Neighbor to display information about\n" | |
10565 | "Display the dampened routes received from neighbor\n") | |
10566 | { | |
10567 | struct peer *peer; | |
10568 | ||
10569 | if (argc == 2) | |
10570 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10571 | else | |
10572 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10573 | ||
10574 | if (! peer) | |
10575 | return CMD_WARNING; | |
10576 | ||
10577 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10578 | bgp_show_type_damp_neighbor); | |
10579 | } | |
10580 | ||
10581 | ALIAS (show_bgp_view_neighbor_damp, | |
10582 | show_bgp_view_ipv6_neighbor_damp_cmd, | |
10583 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10584 | SHOW_STR | |
10585 | BGP_STR | |
10586 | "BGP view\n" | |
10587 | "BGP view name\n" | |
10588 | "Address family\n" | |
10589 | "Detailed information on TCP and BGP neighbor connections\n" | |
10590 | "Neighbor to display information about\n" | |
10591 | "Neighbor to display information about\n" | |
10592 | "Display the dampened routes received from neighbor\n") | |
10593 | ||
10594 | DEFUN (show_bgp_view_neighbor_flap, | |
10595 | show_bgp_view_neighbor_flap_cmd, | |
10596 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10597 | SHOW_STR | |
10598 | BGP_STR | |
10599 | "BGP view\n" | |
10600 | "BGP view name\n" | |
10601 | "Detailed information on TCP and BGP neighbor connections\n" | |
10602 | "Neighbor to display information about\n" | |
10603 | "Neighbor to display information about\n" | |
10604 | "Display flap statistics of the routes learned from neighbor\n") | |
10605 | { | |
10606 | struct peer *peer; | |
10607 | ||
10608 | if (argc == 2) | |
10609 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10610 | else | |
10611 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10612 | ||
10613 | if (! peer) | |
10614 | return CMD_WARNING; | |
10615 | ||
10616 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10617 | bgp_show_type_flap_neighbor); | |
10618 | } | |
10619 | ||
10620 | ALIAS (show_bgp_view_neighbor_flap, | |
10621 | show_bgp_view_ipv6_neighbor_flap_cmd, | |
10622 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10623 | SHOW_STR | |
10624 | BGP_STR | |
10625 | "BGP view\n" | |
10626 | "BGP view name\n" | |
10627 | "Address family\n" | |
10628 | "Detailed information on TCP and BGP neighbor connections\n" | |
10629 | "Neighbor to display information about\n" | |
10630 | "Neighbor to display information about\n" | |
10631 | "Display flap statistics of the routes learned from neighbor\n") | |
10632 | ||
10633 | ALIAS (show_bgp_view_neighbor_routes, | |
10634 | show_bgp_neighbor_routes_cmd, | |
10635 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10636 | SHOW_STR | |
10637 | BGP_STR | |
10638 | "Detailed information on TCP and BGP neighbor connections\n" | |
10639 | "Neighbor to display information about\n" | |
10640 | "Neighbor to display information about\n" | |
10641 | "Display routes learned from neighbor\n") | |
10642 | ||
10643 | ||
10644 | ALIAS (show_bgp_view_neighbor_routes, | |
718e3744 | 10645 | show_bgp_ipv6_neighbor_routes_cmd, |
10646 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
10647 | SHOW_STR | |
10648 | BGP_STR | |
10649 | "Address family\n" | |
10650 | "Detailed information on TCP and BGP neighbor connections\n" | |
10651 | "Neighbor to display information about\n" | |
10652 | "Neighbor to display information about\n" | |
10653 | "Display routes learned from neighbor\n") | |
10654 | ||
10655 | /* old command */ | |
bb46e94f | 10656 | ALIAS (show_bgp_view_neighbor_routes, |
718e3744 | 10657 | ipv6_bgp_neighbor_routes_cmd, |
10658 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10659 | SHOW_STR | |
10660 | IPV6_STR | |
10661 | BGP_STR | |
10662 | "Detailed information on TCP and BGP neighbor connections\n" | |
10663 | "Neighbor to display information about\n" | |
10664 | "Neighbor to display information about\n" | |
10665 | "Display routes learned from neighbor\n") | |
718e3744 | 10666 | |
10667 | /* old command */ | |
10668 | DEFUN (ipv6_mbgp_neighbor_routes, | |
10669 | ipv6_mbgp_neighbor_routes_cmd, | |
10670 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10671 | SHOW_STR | |
10672 | IPV6_STR | |
10673 | MBGP_STR | |
10674 | "Detailed information on TCP and BGP neighbor connections\n" | |
10675 | "Neighbor to display information about\n" | |
10676 | "Neighbor to display information about\n" | |
10677 | "Display routes learned from neighbor\n") | |
10678 | { | |
bb46e94f | 10679 | struct peer *peer; |
10680 | ||
10681 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10682 | if (! peer) | |
10683 | return CMD_WARNING; | |
10684 | ||
10685 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, | |
718e3744 | 10686 | bgp_show_type_neighbor); |
10687 | } | |
bb46e94f | 10688 | |
10689 | ALIAS (show_bgp_view_neighbor_flap, | |
10690 | show_bgp_neighbor_flap_cmd, | |
10691 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10692 | SHOW_STR | |
10693 | BGP_STR | |
10694 | "Detailed information on TCP and BGP neighbor connections\n" | |
10695 | "Neighbor to display information about\n" | |
10696 | "Neighbor to display information about\n" | |
10697 | "Display flap statistics of the routes learned from neighbor\n") | |
10698 | ||
10699 | ALIAS (show_bgp_view_neighbor_flap, | |
10700 | show_bgp_ipv6_neighbor_flap_cmd, | |
10701 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10702 | SHOW_STR | |
10703 | BGP_STR | |
10704 | "Address family\n" | |
10705 | "Detailed information on TCP and BGP neighbor connections\n" | |
10706 | "Neighbor to display information about\n" | |
10707 | "Neighbor to display information about\n" | |
10708 | "Display flap statistics of the routes learned from neighbor\n") | |
10709 | ||
10710 | ALIAS (show_bgp_view_neighbor_damp, | |
10711 | show_bgp_neighbor_damp_cmd, | |
10712 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10713 | SHOW_STR | |
10714 | BGP_STR | |
10715 | "Detailed information on TCP and BGP neighbor connections\n" | |
10716 | "Neighbor to display information about\n" | |
10717 | "Neighbor to display information about\n" | |
10718 | "Display the dampened routes received from neighbor\n") | |
10719 | ||
10720 | ALIAS (show_bgp_view_neighbor_damp, | |
10721 | show_bgp_ipv6_neighbor_damp_cmd, | |
10722 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10723 | SHOW_STR | |
10724 | BGP_STR | |
10725 | "Address family\n" | |
10726 | "Detailed information on TCP and BGP neighbor connections\n" | |
10727 | "Neighbor to display information about\n" | |
10728 | "Neighbor to display information about\n" | |
c001ae62 | 10729 | "Display the dampened routes received from neighbor\n") |
fee0f4c6 | 10730 | |
10731 | DEFUN (show_bgp_view_rsclient, | |
10732 | show_bgp_view_rsclient_cmd, | |
10733 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10734 | SHOW_STR | |
10735 | BGP_STR | |
10736 | "BGP view\n" | |
10737 | "BGP view name\n" | |
10738 | "Information about Route Server Client\n" | |
10739 | NEIGHBOR_ADDR_STR) | |
10740 | { | |
10741 | struct bgp_table *table; | |
10742 | struct peer *peer; | |
10743 | ||
10744 | if (argc == 2) | |
10745 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10746 | else | |
10747 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10748 | ||
10749 | if (! peer) | |
10750 | return CMD_WARNING; | |
10751 | ||
10752 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
10753 | { | |
10754 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10755 | VTY_NEWLINE); | |
10756 | return CMD_WARNING; | |
10757 | } | |
10758 | ||
10759 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
10760 | PEER_FLAG_RSERVER_CLIENT)) | |
10761 | { | |
10762 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10763 | VTY_NEWLINE); | |
10764 | return CMD_WARNING; | |
10765 | } | |
10766 | ||
10767 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; | |
10768 | ||
5a646650 | 10769 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10770 | } |
10771 | ||
10772 | ALIAS (show_bgp_view_rsclient, | |
10773 | show_bgp_rsclient_cmd, | |
10774 | "show bgp rsclient (A.B.C.D|X:X::X:X)", | |
10775 | SHOW_STR | |
10776 | BGP_STR | |
10777 | "Information about Route Server Client\n" | |
10778 | NEIGHBOR_ADDR_STR) | |
10779 | ||
10780 | DEFUN (show_bgp_view_rsclient_route, | |
10781 | show_bgp_view_rsclient_route_cmd, | |
10782 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
10783 | SHOW_STR | |
10784 | BGP_STR | |
10785 | "BGP view\n" | |
10786 | "BGP view name\n" | |
10787 | "Information about Route Server Client\n" | |
10788 | NEIGHBOR_ADDR_STR | |
10789 | "Network in the BGP routing table to display\n") | |
10790 | { | |
10791 | struct bgp *bgp; | |
10792 | struct peer *peer; | |
10793 | ||
10794 | /* BGP structure lookup. */ | |
10795 | if (argc == 3) | |
10796 | { | |
10797 | bgp = bgp_lookup_by_name (argv[0]); | |
10798 | if (bgp == NULL) | |
10799 | { | |
10800 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10801 | return CMD_WARNING; | |
10802 | } | |
10803 | } | |
10804 | else | |
10805 | { | |
10806 | bgp = bgp_get_default (); | |
10807 | if (bgp == NULL) | |
10808 | { | |
10809 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10810 | return CMD_WARNING; | |
10811 | } | |
10812 | } | |
10813 | ||
10814 | if (argc == 3) | |
10815 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10816 | else | |
10817 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10818 | ||
10819 | if (! peer) | |
10820 | return CMD_WARNING; | |
10821 | ||
10822 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
10823 | { | |
10824 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10825 | VTY_NEWLINE); | |
10826 | return CMD_WARNING; | |
10827 | } | |
10828 | ||
10829 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
10830 | PEER_FLAG_RSERVER_CLIENT)) | |
10831 | { | |
10832 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10833 | VTY_NEWLINE); | |
10834 | return CMD_WARNING; | |
10835 | } | |
10836 | ||
10837 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
10838 | (argc == 3) ? argv[2] : argv[1], | |
10839 | AFI_IP6, SAFI_UNICAST, NULL, 0); | |
10840 | } | |
10841 | ||
10842 | ALIAS (show_bgp_view_rsclient_route, | |
10843 | show_bgp_rsclient_route_cmd, | |
10844 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
10845 | SHOW_STR | |
10846 | BGP_STR | |
10847 | "Information about Route Server Client\n" | |
10848 | NEIGHBOR_ADDR_STR | |
10849 | "Network in the BGP routing table to display\n") | |
10850 | ||
10851 | DEFUN (show_bgp_view_rsclient_prefix, | |
10852 | show_bgp_view_rsclient_prefix_cmd, | |
10853 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
10854 | SHOW_STR | |
10855 | BGP_STR | |
10856 | "BGP view\n" | |
10857 | "BGP view name\n" | |
10858 | "Information about Route Server Client\n" | |
10859 | NEIGHBOR_ADDR_STR | |
10860 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
10861 | { | |
10862 | struct bgp *bgp; | |
10863 | struct peer *peer; | |
10864 | ||
10865 | /* BGP structure lookup. */ | |
10866 | if (argc == 3) | |
10867 | { | |
10868 | bgp = bgp_lookup_by_name (argv[0]); | |
10869 | if (bgp == NULL) | |
10870 | { | |
10871 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10872 | return CMD_WARNING; | |
10873 | } | |
10874 | } | |
10875 | else | |
10876 | { | |
10877 | bgp = bgp_get_default (); | |
10878 | if (bgp == NULL) | |
10879 | { | |
10880 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10881 | return CMD_WARNING; | |
10882 | } | |
10883 | } | |
10884 | ||
10885 | if (argc == 3) | |
10886 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10887 | else | |
10888 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10889 | ||
10890 | if (! peer) | |
10891 | return CMD_WARNING; | |
10892 | ||
10893 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
10894 | { | |
10895 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10896 | VTY_NEWLINE); | |
10897 | return CMD_WARNING; | |
10898 | } | |
10899 | ||
10900 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
10901 | PEER_FLAG_RSERVER_CLIENT)) | |
10902 | { | |
10903 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10904 | VTY_NEWLINE); | |
10905 | return CMD_WARNING; | |
10906 | } | |
10907 | ||
10908 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
10909 | (argc == 3) ? argv[2] : argv[1], | |
10910 | AFI_IP6, SAFI_UNICAST, NULL, 1); | |
10911 | } | |
10912 | ||
10913 | ALIAS (show_bgp_view_rsclient_prefix, | |
10914 | show_bgp_rsclient_prefix_cmd, | |
10915 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
10916 | SHOW_STR | |
10917 | BGP_STR | |
10918 | "Information about Route Server Client\n" | |
10919 | NEIGHBOR_ADDR_STR | |
10920 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
10921 | ||
718e3744 | 10922 | #endif /* HAVE_IPV6 */ |
10923 | \f | |
10924 | struct bgp_table *bgp_distance_table; | |
10925 | ||
10926 | struct bgp_distance | |
10927 | { | |
10928 | /* Distance value for the IP source prefix. */ | |
10929 | u_char distance; | |
10930 | ||
10931 | /* Name of the access-list to be matched. */ | |
10932 | char *access_list; | |
10933 | }; | |
10934 | ||
94f2b392 | 10935 | static struct bgp_distance * |
66e5cd87 | 10936 | bgp_distance_new (void) |
718e3744 | 10937 | { |
393deb9b | 10938 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 10939 | } |
10940 | ||
94f2b392 | 10941 | static void |
718e3744 | 10942 | bgp_distance_free (struct bgp_distance *bdistance) |
10943 | { | |
10944 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
10945 | } | |
10946 | ||
94f2b392 | 10947 | static int |
fd79ac91 | 10948 | bgp_distance_set (struct vty *vty, const char *distance_str, |
10949 | const char *ip_str, const char *access_list_str) | |
718e3744 | 10950 | { |
10951 | int ret; | |
10952 | struct prefix_ipv4 p; | |
10953 | u_char distance; | |
10954 | struct bgp_node *rn; | |
10955 | struct bgp_distance *bdistance; | |
10956 | ||
10957 | ret = str2prefix_ipv4 (ip_str, &p); | |
10958 | if (ret == 0) | |
10959 | { | |
10960 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
10961 | return CMD_WARNING; | |
10962 | } | |
10963 | ||
10964 | distance = atoi (distance_str); | |
10965 | ||
10966 | /* Get BGP distance node. */ | |
10967 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
10968 | if (rn->info) | |
10969 | { | |
10970 | bdistance = rn->info; | |
10971 | bgp_unlock_node (rn); | |
10972 | } | |
10973 | else | |
10974 | { | |
10975 | bdistance = bgp_distance_new (); | |
10976 | rn->info = bdistance; | |
10977 | } | |
10978 | ||
10979 | /* Set distance value. */ | |
10980 | bdistance->distance = distance; | |
10981 | ||
10982 | /* Reset access-list configuration. */ | |
10983 | if (bdistance->access_list) | |
10984 | { | |
10985 | free (bdistance->access_list); | |
10986 | bdistance->access_list = NULL; | |
10987 | } | |
10988 | if (access_list_str) | |
10989 | bdistance->access_list = strdup (access_list_str); | |
10990 | ||
10991 | return CMD_SUCCESS; | |
10992 | } | |
10993 | ||
94f2b392 | 10994 | static int |
fd79ac91 | 10995 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
10996 | const char *ip_str, const char *access_list_str) | |
718e3744 | 10997 | { |
10998 | int ret; | |
10999 | struct prefix_ipv4 p; | |
11000 | u_char distance; | |
11001 | struct bgp_node *rn; | |
11002 | struct bgp_distance *bdistance; | |
11003 | ||
11004 | ret = str2prefix_ipv4 (ip_str, &p); | |
11005 | if (ret == 0) | |
11006 | { | |
11007 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11008 | return CMD_WARNING; | |
11009 | } | |
11010 | ||
11011 | distance = atoi (distance_str); | |
11012 | ||
11013 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); | |
11014 | if (! rn) | |
11015 | { | |
11016 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
11017 | return CMD_WARNING; | |
11018 | } | |
11019 | ||
11020 | bdistance = rn->info; | |
11021 | ||
11022 | if (bdistance->access_list) | |
11023 | free (bdistance->access_list); | |
11024 | bgp_distance_free (bdistance); | |
11025 | ||
11026 | rn->info = NULL; | |
11027 | bgp_unlock_node (rn); | |
11028 | bgp_unlock_node (rn); | |
11029 | ||
11030 | return CMD_SUCCESS; | |
11031 | } | |
11032 | ||
94f2b392 | 11033 | static void |
66e5cd87 | 11034 | bgp_distance_reset (void) |
718e3744 | 11035 | { |
11036 | struct bgp_node *rn; | |
11037 | struct bgp_distance *bdistance; | |
11038 | ||
11039 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
11040 | if ((bdistance = rn->info) != NULL) | |
11041 | { | |
11042 | if (bdistance->access_list) | |
11043 | free (bdistance->access_list); | |
11044 | bgp_distance_free (bdistance); | |
11045 | rn->info = NULL; | |
11046 | bgp_unlock_node (rn); | |
11047 | } | |
11048 | } | |
11049 | ||
11050 | /* Apply BGP information to distance method. */ | |
11051 | u_char | |
11052 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
11053 | { | |
11054 | struct bgp_node *rn; | |
11055 | struct prefix_ipv4 q; | |
11056 | struct peer *peer; | |
11057 | struct bgp_distance *bdistance; | |
11058 | struct access_list *alist; | |
11059 | struct bgp_static *bgp_static; | |
11060 | ||
11061 | if (! bgp) | |
11062 | return 0; | |
11063 | ||
11064 | if (p->family != AF_INET) | |
11065 | return 0; | |
11066 | ||
11067 | peer = rinfo->peer; | |
11068 | ||
11069 | if (peer->su.sa.sa_family != AF_INET) | |
11070 | return 0; | |
11071 | ||
11072 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
11073 | q.family = AF_INET; | |
11074 | q.prefix = peer->su.sin.sin_addr; | |
11075 | q.prefixlen = IPV4_MAX_BITLEN; | |
11076 | ||
11077 | /* Check source address. */ | |
11078 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
11079 | if (rn) | |
11080 | { | |
11081 | bdistance = rn->info; | |
11082 | bgp_unlock_node (rn); | |
11083 | ||
11084 | if (bdistance->access_list) | |
11085 | { | |
11086 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
11087 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
11088 | return bdistance->distance; | |
11089 | } | |
11090 | else | |
11091 | return bdistance->distance; | |
11092 | } | |
11093 | ||
11094 | /* Backdoor check. */ | |
11095 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
11096 | if (rn) | |
11097 | { | |
11098 | bgp_static = rn->info; | |
11099 | bgp_unlock_node (rn); | |
11100 | ||
11101 | if (bgp_static->backdoor) | |
11102 | { | |
11103 | if (bgp->distance_local) | |
11104 | return bgp->distance_local; | |
11105 | else | |
11106 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11107 | } | |
11108 | } | |
11109 | ||
11110 | if (peer_sort (peer) == BGP_PEER_EBGP) | |
11111 | { | |
11112 | if (bgp->distance_ebgp) | |
11113 | return bgp->distance_ebgp; | |
11114 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
11115 | } | |
11116 | else | |
11117 | { | |
11118 | if (bgp->distance_ibgp) | |
11119 | return bgp->distance_ibgp; | |
11120 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11121 | } | |
11122 | } | |
11123 | ||
11124 | DEFUN (bgp_distance, | |
11125 | bgp_distance_cmd, | |
11126 | "distance bgp <1-255> <1-255> <1-255>", | |
11127 | "Define an administrative distance\n" | |
11128 | "BGP distance\n" | |
11129 | "Distance for routes external to the AS\n" | |
11130 | "Distance for routes internal to the AS\n" | |
11131 | "Distance for local routes\n") | |
11132 | { | |
11133 | struct bgp *bgp; | |
11134 | ||
11135 | bgp = vty->index; | |
11136 | ||
11137 | bgp->distance_ebgp = atoi (argv[0]); | |
11138 | bgp->distance_ibgp = atoi (argv[1]); | |
11139 | bgp->distance_local = atoi (argv[2]); | |
11140 | return CMD_SUCCESS; | |
11141 | } | |
11142 | ||
11143 | DEFUN (no_bgp_distance, | |
11144 | no_bgp_distance_cmd, | |
11145 | "no distance bgp <1-255> <1-255> <1-255>", | |
11146 | NO_STR | |
11147 | "Define an administrative distance\n" | |
11148 | "BGP distance\n" | |
11149 | "Distance for routes external to the AS\n" | |
11150 | "Distance for routes internal to the AS\n" | |
11151 | "Distance for local routes\n") | |
11152 | { | |
11153 | struct bgp *bgp; | |
11154 | ||
11155 | bgp = vty->index; | |
11156 | ||
11157 | bgp->distance_ebgp= 0; | |
11158 | bgp->distance_ibgp = 0; | |
11159 | bgp->distance_local = 0; | |
11160 | return CMD_SUCCESS; | |
11161 | } | |
11162 | ||
11163 | ALIAS (no_bgp_distance, | |
11164 | no_bgp_distance2_cmd, | |
11165 | "no distance bgp", | |
11166 | NO_STR | |
11167 | "Define an administrative distance\n" | |
11168 | "BGP distance\n") | |
11169 | ||
11170 | DEFUN (bgp_distance_source, | |
11171 | bgp_distance_source_cmd, | |
11172 | "distance <1-255> A.B.C.D/M", | |
11173 | "Define an administrative distance\n" | |
11174 | "Administrative distance\n" | |
11175 | "IP source prefix\n") | |
11176 | { | |
11177 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
11178 | return CMD_SUCCESS; | |
11179 | } | |
11180 | ||
11181 | DEFUN (no_bgp_distance_source, | |
11182 | no_bgp_distance_source_cmd, | |
11183 | "no distance <1-255> A.B.C.D/M", | |
11184 | NO_STR | |
11185 | "Define an administrative distance\n" | |
11186 | "Administrative distance\n" | |
11187 | "IP source prefix\n") | |
11188 | { | |
11189 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
11190 | return CMD_SUCCESS; | |
11191 | } | |
11192 | ||
11193 | DEFUN (bgp_distance_source_access_list, | |
11194 | bgp_distance_source_access_list_cmd, | |
11195 | "distance <1-255> A.B.C.D/M WORD", | |
11196 | "Define an administrative distance\n" | |
11197 | "Administrative distance\n" | |
11198 | "IP source prefix\n" | |
11199 | "Access list name\n") | |
11200 | { | |
11201 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
11202 | return CMD_SUCCESS; | |
11203 | } | |
11204 | ||
11205 | DEFUN (no_bgp_distance_source_access_list, | |
11206 | no_bgp_distance_source_access_list_cmd, | |
11207 | "no distance <1-255> A.B.C.D/M WORD", | |
11208 | NO_STR | |
11209 | "Define an administrative distance\n" | |
11210 | "Administrative distance\n" | |
11211 | "IP source prefix\n" | |
11212 | "Access list name\n") | |
11213 | { | |
11214 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
11215 | return CMD_SUCCESS; | |
11216 | } | |
11217 | \f | |
11218 | DEFUN (bgp_damp_set, | |
11219 | bgp_damp_set_cmd, | |
11220 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11221 | "BGP Specific commands\n" | |
11222 | "Enable route-flap dampening\n" | |
11223 | "Half-life time for the penalty\n" | |
11224 | "Value to start reusing a route\n" | |
11225 | "Value to start suppressing a route\n" | |
11226 | "Maximum duration to suppress a stable route\n") | |
11227 | { | |
11228 | struct bgp *bgp; | |
11229 | int half = DEFAULT_HALF_LIFE * 60; | |
11230 | int reuse = DEFAULT_REUSE; | |
11231 | int suppress = DEFAULT_SUPPRESS; | |
11232 | int max = 4 * half; | |
11233 | ||
11234 | if (argc == 4) | |
11235 | { | |
11236 | half = atoi (argv[0]) * 60; | |
11237 | reuse = atoi (argv[1]); | |
11238 | suppress = atoi (argv[2]); | |
11239 | max = atoi (argv[3]) * 60; | |
11240 | } | |
11241 | else if (argc == 1) | |
11242 | { | |
11243 | half = atoi (argv[0]) * 60; | |
11244 | max = 4 * half; | |
11245 | } | |
11246 | ||
11247 | bgp = vty->index; | |
11248 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), | |
11249 | half, reuse, suppress, max); | |
11250 | } | |
11251 | ||
11252 | ALIAS (bgp_damp_set, | |
11253 | bgp_damp_set2_cmd, | |
11254 | "bgp dampening <1-45>", | |
11255 | "BGP Specific commands\n" | |
11256 | "Enable route-flap dampening\n" | |
11257 | "Half-life time for the penalty\n") | |
11258 | ||
11259 | ALIAS (bgp_damp_set, | |
11260 | bgp_damp_set3_cmd, | |
11261 | "bgp dampening", | |
11262 | "BGP Specific commands\n" | |
11263 | "Enable route-flap dampening\n") | |
11264 | ||
11265 | DEFUN (bgp_damp_unset, | |
11266 | bgp_damp_unset_cmd, | |
11267 | "no bgp dampening", | |
11268 | NO_STR | |
11269 | "BGP Specific commands\n" | |
11270 | "Enable route-flap dampening\n") | |
11271 | { | |
11272 | struct bgp *bgp; | |
11273 | ||
11274 | bgp = vty->index; | |
11275 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
11276 | } | |
11277 | ||
11278 | ALIAS (bgp_damp_unset, | |
11279 | bgp_damp_unset2_cmd, | |
11280 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11281 | NO_STR | |
11282 | "BGP Specific commands\n" | |
11283 | "Enable route-flap dampening\n" | |
11284 | "Half-life time for the penalty\n" | |
11285 | "Value to start reusing a route\n" | |
11286 | "Value to start suppressing a route\n" | |
11287 | "Maximum duration to suppress a stable route\n") | |
11288 | ||
11289 | DEFUN (show_ip_bgp_dampened_paths, | |
11290 | show_ip_bgp_dampened_paths_cmd, | |
11291 | "show ip bgp dampened-paths", | |
11292 | SHOW_STR | |
11293 | IP_STR | |
11294 | BGP_STR | |
11295 | "Display paths suppressed due to dampening\n") | |
11296 | { | |
5a646650 | 11297 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
11298 | NULL); | |
718e3744 | 11299 | } |
11300 | ||
11301 | DEFUN (show_ip_bgp_flap_statistics, | |
11302 | show_ip_bgp_flap_statistics_cmd, | |
11303 | "show ip bgp flap-statistics", | |
11304 | SHOW_STR | |
11305 | IP_STR | |
11306 | BGP_STR | |
11307 | "Display flap statistics of routes\n") | |
11308 | { | |
5a646650 | 11309 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
11310 | bgp_show_type_flap_statistics, NULL); | |
718e3744 | 11311 | } |
11312 | \f | |
11313 | /* Display specified route of BGP table. */ | |
94f2b392 | 11314 | static int |
fd79ac91 | 11315 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
11316 | const char *ip_str, afi_t afi, safi_t safi, | |
11317 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 11318 | { |
11319 | int ret; | |
11320 | struct prefix match; | |
11321 | struct bgp_node *rn; | |
11322 | struct bgp_node *rm; | |
11323 | struct bgp_info *ri; | |
11324 | struct bgp_info *ri_temp; | |
11325 | struct bgp *bgp; | |
11326 | struct bgp_table *table; | |
11327 | ||
11328 | /* BGP structure lookup. */ | |
11329 | if (view_name) | |
11330 | { | |
11331 | bgp = bgp_lookup_by_name (view_name); | |
11332 | if (bgp == NULL) | |
11333 | { | |
11334 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
11335 | return CMD_WARNING; | |
11336 | } | |
11337 | } | |
11338 | else | |
11339 | { | |
11340 | bgp = bgp_get_default (); | |
11341 | if (bgp == NULL) | |
11342 | { | |
11343 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
11344 | return CMD_WARNING; | |
11345 | } | |
11346 | } | |
11347 | ||
11348 | /* Check IP address argument. */ | |
11349 | ret = str2prefix (ip_str, &match); | |
11350 | if (! ret) | |
11351 | { | |
11352 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
11353 | return CMD_WARNING; | |
11354 | } | |
11355 | ||
11356 | match.family = afi2family (afi); | |
11357 | ||
11358 | if (safi == SAFI_MPLS_VPN) | |
11359 | { | |
11360 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) | |
11361 | { | |
11362 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
11363 | continue; | |
11364 | ||
11365 | if ((table = rn->info) != NULL) | |
11366 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
11367 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
11368 | { | |
11369 | ri = rm->info; | |
11370 | while (ri) | |
11371 | { | |
fb982c25 | 11372 | if (ri->extra && ri->extra->damp_info) |
718e3744 | 11373 | { |
11374 | ri_temp = ri->next; | |
fb982c25 | 11375 | bgp_damp_info_free (ri->extra->damp_info, 1); |
718e3744 | 11376 | ri = ri_temp; |
11377 | } | |
11378 | else | |
11379 | ri = ri->next; | |
11380 | } | |
11381 | } | |
11382 | } | |
11383 | } | |
11384 | else | |
11385 | { | |
11386 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
11387 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
11388 | { | |
11389 | ri = rn->info; | |
11390 | while (ri) | |
11391 | { | |
fb982c25 | 11392 | if (ri->extra && ri->extra->damp_info) |
718e3744 | 11393 | { |
11394 | ri_temp = ri->next; | |
fb982c25 | 11395 | bgp_damp_info_free (ri->extra->damp_info, 1); |
718e3744 | 11396 | ri = ri_temp; |
11397 | } | |
11398 | else | |
11399 | ri = ri->next; | |
11400 | } | |
11401 | } | |
11402 | } | |
11403 | ||
11404 | return CMD_SUCCESS; | |
11405 | } | |
11406 | ||
11407 | DEFUN (clear_ip_bgp_dampening, | |
11408 | clear_ip_bgp_dampening_cmd, | |
11409 | "clear ip bgp dampening", | |
11410 | CLEAR_STR | |
11411 | IP_STR | |
11412 | BGP_STR | |
11413 | "Clear route flap dampening information\n") | |
11414 | { | |
11415 | bgp_damp_info_clean (); | |
11416 | return CMD_SUCCESS; | |
11417 | } | |
11418 | ||
11419 | DEFUN (clear_ip_bgp_dampening_prefix, | |
11420 | clear_ip_bgp_dampening_prefix_cmd, | |
11421 | "clear ip bgp dampening A.B.C.D/M", | |
11422 | CLEAR_STR | |
11423 | IP_STR | |
11424 | BGP_STR | |
11425 | "Clear route flap dampening information\n" | |
11426 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
11427 | { | |
11428 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
11429 | SAFI_UNICAST, NULL, 1); | |
11430 | } | |
11431 | ||
11432 | DEFUN (clear_ip_bgp_dampening_address, | |
11433 | clear_ip_bgp_dampening_address_cmd, | |
11434 | "clear ip bgp dampening A.B.C.D", | |
11435 | CLEAR_STR | |
11436 | IP_STR | |
11437 | BGP_STR | |
11438 | "Clear route flap dampening information\n" | |
11439 | "Network to clear damping information\n") | |
11440 | { | |
11441 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
11442 | SAFI_UNICAST, NULL, 0); | |
11443 | } | |
11444 | ||
11445 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
11446 | clear_ip_bgp_dampening_address_mask_cmd, | |
11447 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
11448 | CLEAR_STR | |
11449 | IP_STR | |
11450 | BGP_STR | |
11451 | "Clear route flap dampening information\n" | |
11452 | "Network to clear damping information\n" | |
11453 | "Network mask\n") | |
11454 | { | |
11455 | int ret; | |
11456 | char prefix_str[BUFSIZ]; | |
11457 | ||
11458 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
11459 | if (! ret) | |
11460 | { | |
11461 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
11462 | return CMD_WARNING; | |
11463 | } | |
11464 | ||
11465 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
11466 | SAFI_UNICAST, NULL, 0); | |
11467 | } | |
11468 | \f | |
94f2b392 | 11469 | static int |
718e3744 | 11470 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
11471 | afi_t afi, safi_t safi, int *write) | |
11472 | { | |
11473 | struct bgp_node *prn; | |
11474 | struct bgp_node *rn; | |
11475 | struct bgp_table *table; | |
11476 | struct prefix *p; | |
11477 | struct prefix_rd *prd; | |
11478 | struct bgp_static *bgp_static; | |
11479 | u_int32_t label; | |
11480 | char buf[SU_ADDRSTRLEN]; | |
11481 | char rdbuf[RD_ADDRSTRLEN]; | |
11482 | ||
11483 | /* Network configuration. */ | |
11484 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
11485 | if ((table = prn->info) != NULL) | |
11486 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
11487 | if ((bgp_static = rn->info) != NULL) | |
11488 | { | |
11489 | p = &rn->p; | |
11490 | prd = (struct prefix_rd *) &prn->p; | |
11491 | ||
11492 | /* "address-family" display. */ | |
11493 | bgp_config_write_family_header (vty, afi, safi, write); | |
11494 | ||
11495 | /* "network" configuration display. */ | |
11496 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
11497 | label = decode_label (bgp_static->tag); | |
11498 | ||
11499 | vty_out (vty, " network %s/%d rd %s tag %d", | |
11500 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11501 | p->prefixlen, | |
11502 | rdbuf, label); | |
11503 | vty_out (vty, "%s", VTY_NEWLINE); | |
11504 | } | |
11505 | return 0; | |
11506 | } | |
11507 | ||
11508 | /* Configuration of static route announcement and aggregate | |
11509 | information. */ | |
11510 | int | |
11511 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
11512 | afi_t afi, safi_t safi, int *write) | |
11513 | { | |
11514 | struct bgp_node *rn; | |
11515 | struct prefix *p; | |
11516 | struct bgp_static *bgp_static; | |
11517 | struct bgp_aggregate *bgp_aggregate; | |
11518 | char buf[SU_ADDRSTRLEN]; | |
11519 | ||
11520 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
11521 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); | |
11522 | ||
11523 | /* Network configuration. */ | |
11524 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
11525 | if ((bgp_static = rn->info) != NULL) | |
11526 | { | |
11527 | p = &rn->p; | |
11528 | ||
11529 | /* "address-family" display. */ | |
11530 | bgp_config_write_family_header (vty, afi, safi, write); | |
11531 | ||
11532 | /* "network" configuration display. */ | |
11533 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
11534 | { | |
11535 | u_int32_t destination; | |
11536 | struct in_addr netmask; | |
11537 | ||
11538 | destination = ntohl (p->u.prefix4.s_addr); | |
11539 | masklen2ip (p->prefixlen, &netmask); | |
11540 | vty_out (vty, " network %s", | |
11541 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); | |
11542 | ||
11543 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
11544 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
11545 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
11546 | || p->u.prefix4.s_addr == 0) | |
11547 | { | |
11548 | /* Natural mask is not display. */ | |
11549 | } | |
11550 | else | |
11551 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
11552 | } | |
11553 | else | |
11554 | { | |
11555 | vty_out (vty, " network %s/%d", | |
11556 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11557 | p->prefixlen); | |
11558 | } | |
11559 | ||
11560 | if (bgp_static->rmap.name) | |
11561 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
11562 | else |
11563 | { | |
11564 | if (bgp_static->backdoor) | |
11565 | vty_out (vty, " backdoor"); | |
11566 | if (bgp_static->ttl) | |
11567 | vty_out (vty, " pathlimit %u", bgp_static->ttl); | |
11568 | } | |
718e3744 | 11569 | |
11570 | vty_out (vty, "%s", VTY_NEWLINE); | |
11571 | } | |
11572 | ||
11573 | /* Aggregate-address configuration. */ | |
11574 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
11575 | if ((bgp_aggregate = rn->info) != NULL) | |
11576 | { | |
11577 | p = &rn->p; | |
11578 | ||
11579 | /* "address-family" display. */ | |
11580 | bgp_config_write_family_header (vty, afi, safi, write); | |
11581 | ||
11582 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
11583 | { | |
11584 | struct in_addr netmask; | |
11585 | ||
11586 | masklen2ip (p->prefixlen, &netmask); | |
11587 | vty_out (vty, " aggregate-address %s %s", | |
11588 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11589 | inet_ntoa (netmask)); | |
11590 | } | |
11591 | else | |
11592 | { | |
11593 | vty_out (vty, " aggregate-address %s/%d", | |
11594 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11595 | p->prefixlen); | |
11596 | } | |
11597 | ||
11598 | if (bgp_aggregate->as_set) | |
11599 | vty_out (vty, " as-set"); | |
11600 | ||
11601 | if (bgp_aggregate->summary_only) | |
11602 | vty_out (vty, " summary-only"); | |
11603 | ||
11604 | vty_out (vty, "%s", VTY_NEWLINE); | |
11605 | } | |
11606 | ||
11607 | return 0; | |
11608 | } | |
11609 | ||
11610 | int | |
11611 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
11612 | { | |
11613 | struct bgp_node *rn; | |
11614 | struct bgp_distance *bdistance; | |
11615 | ||
11616 | /* Distance configuration. */ | |
11617 | if (bgp->distance_ebgp | |
11618 | && bgp->distance_ibgp | |
11619 | && bgp->distance_local | |
11620 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
11621 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
11622 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
11623 | vty_out (vty, " distance bgp %d %d %d%s", | |
11624 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
11625 | VTY_NEWLINE); | |
11626 | ||
11627 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
11628 | if ((bdistance = rn->info) != NULL) | |
11629 | { | |
11630 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
11631 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
11632 | bdistance->access_list ? bdistance->access_list : "", | |
11633 | VTY_NEWLINE); | |
11634 | } | |
11635 | ||
11636 | return 0; | |
11637 | } | |
11638 | ||
11639 | /* Allocate routing table structure and install commands. */ | |
11640 | void | |
66e5cd87 | 11641 | bgp_route_init (void) |
718e3744 | 11642 | { |
11643 | /* Init BGP distance table. */ | |
64e580a7 | 11644 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 11645 | |
11646 | /* IPv4 BGP commands. */ | |
11647 | install_element (BGP_NODE, &bgp_network_cmd); | |
11648 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
11649 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
11650 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
11651 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
11652 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
11653 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
11654 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
11655 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
41367172 PJ |
11656 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
11657 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); | |
11658 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); | |
11659 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); | |
11660 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
11661 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
718e3744 | 11662 | install_element (BGP_NODE, &no_bgp_network_cmd); |
11663 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
11664 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
11665 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
11666 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
11667 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
11668 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
11669 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
11670 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
41367172 PJ |
11671 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
11672 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); | |
11673 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
11674 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
11675 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
11676 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
718e3744 | 11677 | |
11678 | install_element (BGP_NODE, &aggregate_address_cmd); | |
11679 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
11680 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
11681 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
11682 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
11683 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
11684 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
11685 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
11686 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
11687 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
11688 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
11689 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
11690 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
11691 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
11692 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
11693 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
11694 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
11695 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
11696 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
11697 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
11698 | ||
11699 | /* IPv4 unicast configuration. */ | |
11700 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); | |
11701 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
11702 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
11703 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
11704 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
11705 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11706 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
11707 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); | |
11708 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); | |
11709 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); | |
11710 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
11711 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11712 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
11713 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
11714 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
11715 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
11716 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11717 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
11718 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); | |
11719 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
11720 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
11721 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
11722 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11723 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
11724 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
11725 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
11726 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
11727 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
11728 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
11729 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
11730 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
11731 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
11732 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
11733 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
11734 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
11735 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
11736 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
11737 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
11738 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
11739 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
11740 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
11741 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
11742 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
11743 | ||
11744 | /* IPv4 multicast configuration. */ | |
11745 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); | |
11746 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
11747 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
11748 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
11749 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
11750 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11751 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
11752 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); | |
11753 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); | |
11754 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); | |
11755 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
11756 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11757 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
11758 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
11759 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
11760 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
11761 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
11762 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11763 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
11764 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); | |
11765 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
11766 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
11767 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
11768 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11769 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
11770 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
11771 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
11772 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
11773 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
11774 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
11775 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
11776 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
11777 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
11778 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
11779 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
11780 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
11781 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
11782 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
11783 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
11784 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
11785 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
11786 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
11787 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
11788 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
11789 | ||
11790 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
11791 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); | |
11792 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); | |
11793 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); | |
11794 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); | |
11795 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
11796 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
11797 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
11798 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); | |
11799 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
11800 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); | |
11801 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); | |
11802 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); | |
11803 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); | |
11804 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
11805 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
11806 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
11807 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
11808 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
11809 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
11810 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
11811 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
11812 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
11813 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
11814 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
11815 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
11816 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
11817 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
11818 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
11819 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
11820 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
11821 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
11822 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
11823 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); | |
11824 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
11825 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
11826 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
11827 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
11828 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
11829 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
11830 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
11831 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
11832 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
11833 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
11834 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
11835 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
11836 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
11837 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
11838 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
11839 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
11840 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
11841 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); | |
11842 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
11843 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
11844 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
11845 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); | |
11846 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); | |
11847 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); | |
11848 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); | |
11849 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
11850 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); | |
11851 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
11852 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
11853 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
11854 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); | |
11855 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
11856 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 11857 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
11858 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); | |
11859 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); | |
2a71e9ce TP |
11860 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
11861 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 11862 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
11863 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); | |
11864 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); | |
62687ff1 PJ |
11865 | |
11866 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
11867 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
11868 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); | |
11869 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
11870 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
11871 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
11872 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); | |
11873 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
11874 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); | |
11875 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); | |
11876 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); | |
11877 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
11878 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
11879 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
11880 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
11881 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
11882 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
11883 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
11884 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); | |
11885 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
11886 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
11887 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
11888 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
11889 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
11890 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
11891 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
11892 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); | |
11893 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); | |
11894 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); | |
11895 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); | |
718e3744 | 11896 | |
11897 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
11898 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); | |
11899 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); | |
11900 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); | |
11901 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); | |
11902 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
11903 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
11904 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
11905 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); | |
11906 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
11907 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); | |
11908 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); | |
11909 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); | |
11910 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); | |
11911 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
11912 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
11913 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
11914 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
11915 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
11916 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
11917 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
11918 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
11919 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
11920 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
11921 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
11922 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
11923 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
11924 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
11925 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
11926 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
11927 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
11928 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
11929 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
11930 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); | |
11931 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
11932 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
11933 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
11934 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
11935 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
11936 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
11937 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
11938 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
11939 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
11940 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
11941 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
11942 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
11943 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
11944 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
11945 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
11946 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
11947 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
11948 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); | |
11949 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
11950 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
11951 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
11952 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); | |
11953 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); | |
11954 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); | |
11955 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); | |
11956 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
11957 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); | |
11958 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
11959 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
11960 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
11961 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); | |
11962 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
11963 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 11964 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
11965 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); | |
11966 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); | |
2a71e9ce TP |
11967 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
11968 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 11969 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
11970 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); | |
11971 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); | |
718e3744 | 11972 | |
11973 | /* BGP dampening clear commands */ | |
11974 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
11975 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
11976 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
11977 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
11978 | ||
ff7924f6 PJ |
11979 | /* prefix count */ |
11980 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
11981 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); | |
11982 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 11983 | #ifdef HAVE_IPV6 |
ff7924f6 PJ |
11984 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
11985 | ||
718e3744 | 11986 | /* New config IPv6 BGP commands. */ |
11987 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); | |
11988 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
41367172 | 11989 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
718e3744 | 11990 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
11991 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
41367172 | 11992 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
718e3744 | 11993 | |
11994 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
11995 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
11996 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
11997 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
11998 | ||
11999 | /* Old config IPv6 BGP commands. */ | |
12000 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
12001 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
12002 | ||
12003 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
12004 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
12005 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
12006 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
12007 | ||
12008 | install_element (VIEW_NODE, &show_bgp_cmd); | |
12009 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
12010 | install_element (VIEW_NODE, &show_bgp_route_cmd); | |
12011 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
12012 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); | |
12013 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
12014 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); | |
12015 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
12016 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
12017 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12018 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
12019 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12020 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
12021 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
12022 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
12023 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
12024 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
12025 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
12026 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
12027 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
12028 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
12029 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
12030 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
12031 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
12032 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
12033 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12034 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
12035 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12036 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
12037 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12038 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
12039 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12040 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
12041 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
12042 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
12043 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12044 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
12045 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12046 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12047 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12048 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12049 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12050 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
12051 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12052 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12053 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12054 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
12055 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12056 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
12057 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12058 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
12059 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); | |
12060 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); | |
bb46e94f | 12061 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
12062 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); | |
12063 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); | |
12064 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); | |
12065 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); | |
12066 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12067 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12068 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12069 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12070 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12071 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12072 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12073 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12074 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12075 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12076 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12077 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12078 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12079 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
12080 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); | |
12081 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); | |
62687ff1 PJ |
12082 | |
12083 | /* Restricted: | |
12084 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
12085 | */ | |
12086 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
12087 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
12088 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); | |
12089 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
12090 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); | |
12091 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
12092 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
12093 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
12094 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
12095 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
12096 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
12097 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
12098 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
12099 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12100 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
12101 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12102 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
12103 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12104 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
12105 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12106 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); | |
12107 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); | |
12108 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); | |
12109 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); | |
12110 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); | |
12111 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12112 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12113 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12114 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); | |
12115 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); | |
718e3744 | 12116 | |
12117 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
12118 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
12119 | install_element (ENABLE_NODE, &show_bgp_route_cmd); | |
12120 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
12121 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); | |
12122 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); | |
12123 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); | |
12124 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
12125 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
12126 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12127 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
12128 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12129 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
12130 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
12131 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
12132 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
12133 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
12134 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
12135 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
12136 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
12137 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
12138 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
12139 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
12140 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
12141 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
12142 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12143 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
12144 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12145 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
12146 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12147 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
12148 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12149 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
12150 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
12151 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
12152 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12153 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
12154 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12155 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12156 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12157 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12158 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12159 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
12160 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12161 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12162 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12163 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
12164 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12165 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
12166 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12167 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
12168 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); | |
12169 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); | |
bb46e94f | 12170 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
12171 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); | |
12172 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); | |
12173 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); | |
12174 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); | |
12175 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12176 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12177 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12178 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12179 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12180 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12181 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12182 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12183 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12184 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12185 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12186 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12187 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12188 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
12189 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); | |
12190 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); | |
2815e61f PJ |
12191 | |
12192 | /* Statistics */ | |
12193 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
12194 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); | |
12195 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); | |
12196 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); | |
12197 | ||
718e3744 | 12198 | /* old command */ |
12199 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
12200 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
12201 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
12202 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
12203 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12204 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12205 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
12206 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
12207 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
12208 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
12209 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
12210 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12211 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12212 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12213 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12214 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
12215 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12216 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12217 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
12218 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
12219 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12220 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12221 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12222 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12223 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12224 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
12225 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
12226 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
12227 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
12228 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12229 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12230 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12231 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12232 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12233 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12234 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 12235 | |
718e3744 | 12236 | /* old command */ |
12237 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
12238 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
12239 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
12240 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
12241 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12242 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12243 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
12244 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
12245 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
12246 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
12247 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
12248 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12249 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12250 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12251 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12252 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
12253 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12254 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12255 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
12256 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
12257 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12258 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12259 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12260 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12261 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12262 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
12263 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
12264 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
12265 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
12266 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12267 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12268 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12269 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12270 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12271 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12272 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
12273 | ||
12274 | /* old command */ | |
12275 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12276 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12277 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12278 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12279 | ||
12280 | /* old command */ | |
12281 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12282 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12283 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12284 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12285 | ||
12286 | /* old command */ | |
12287 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12288 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12289 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12290 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12291 | #endif /* HAVE_IPV6 */ | |
12292 | ||
12293 | install_element (BGP_NODE, &bgp_distance_cmd); | |
12294 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
12295 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
12296 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
12297 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
12298 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
12299 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
12300 | ||
12301 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
12302 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
12303 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
12304 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
12305 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
12306 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); | |
12307 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
12308 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
12309 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
12310 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
12311 | } | |
228da428 CC |
12312 | |
12313 | void | |
12314 | bgp_route_finish (void) | |
12315 | { | |
12316 | bgp_table_unlock (bgp_distance_table); | |
12317 | bgp_distance_table = NULL; | |
12318 | } |