]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP routing information |
2 | Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro | |
3 | ||
4 | This file is part of GNU Zebra. | |
5 | ||
6 | GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 2, or (at your option) any | |
9 | later version. | |
10 | ||
11 | GNU Zebra is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "prefix.h" | |
24 | #include "linklist.h" | |
25 | #include "memory.h" | |
26 | #include "command.h" | |
27 | #include "stream.h" | |
28 | #include "filter.h" | |
29 | #include "str.h" | |
30 | #include "log.h" | |
31 | #include "routemap.h" | |
32 | #include "buffer.h" | |
33 | #include "sockunion.h" | |
34 | #include "plist.h" | |
35 | #include "thread.h" | |
200df115 | 36 | #include "workqueue.h" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
39 | #include "bgpd/bgp_table.h" | |
40 | #include "bgpd/bgp_route.h" | |
41 | #include "bgpd/bgp_attr.h" | |
42 | #include "bgpd/bgp_debug.h" | |
43 | #include "bgpd/bgp_aspath.h" | |
44 | #include "bgpd/bgp_regex.h" | |
45 | #include "bgpd/bgp_community.h" | |
46 | #include "bgpd/bgp_ecommunity.h" | |
47 | #include "bgpd/bgp_clist.h" | |
48 | #include "bgpd/bgp_packet.h" | |
49 | #include "bgpd/bgp_filter.h" | |
50 | #include "bgpd/bgp_fsm.h" | |
51 | #include "bgpd/bgp_mplsvpn.h" | |
52 | #include "bgpd/bgp_nexthop.h" | |
53 | #include "bgpd/bgp_damp.h" | |
54 | #include "bgpd/bgp_advertise.h" | |
55 | #include "bgpd/bgp_zebra.h" | |
0a486e5f | 56 | #include "bgpd/bgp_vty.h" |
96450faf | 57 | #include "bgpd/bgp_mpath.h" |
718e3744 | 58 | |
59 | /* Extern from bgp_dump.c */ | |
dde72586 SH |
60 | extern const char *bgp_origin_str[]; |
61 | extern const char *bgp_origin_long_str[]; | |
718e3744 | 62 | \f |
94f2b392 | 63 | static struct bgp_node * |
fee0f4c6 | 64 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
718e3744 | 65 | struct prefix_rd *prd) |
66 | { | |
67 | struct bgp_node *rn; | |
68 | struct bgp_node *prn = NULL; | |
da5b30f6 PJ |
69 | |
70 | assert (table); | |
71 | if (!table) | |
72 | return NULL; | |
73 | ||
718e3744 | 74 | if (safi == SAFI_MPLS_VPN) |
75 | { | |
fee0f4c6 | 76 | prn = bgp_node_get (table, (struct prefix *) prd); |
718e3744 | 77 | |
78 | if (prn->info == NULL) | |
64e580a7 | 79 | prn->info = bgp_table_init (afi, safi); |
718e3744 | 80 | else |
81 | bgp_unlock_node (prn); | |
82 | table = prn->info; | |
83 | } | |
718e3744 | 84 | |
85 | rn = bgp_node_get (table, p); | |
86 | ||
87 | if (safi == SAFI_MPLS_VPN) | |
88 | rn->prn = prn; | |
89 | ||
90 | return rn; | |
91 | } | |
92 | \f | |
fb982c25 PJ |
93 | /* Allocate bgp_info_extra */ |
94 | static struct bgp_info_extra * | |
95 | bgp_info_extra_new (void) | |
96 | { | |
97 | struct bgp_info_extra *new; | |
98 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); | |
99 | return new; | |
100 | } | |
101 | ||
102 | static void | |
103 | bgp_info_extra_free (struct bgp_info_extra **extra) | |
104 | { | |
105 | if (extra && *extra) | |
106 | { | |
107 | if ((*extra)->damp_info) | |
108 | bgp_damp_info_free ((*extra)->damp_info, 0); | |
109 | ||
110 | (*extra)->damp_info = NULL; | |
111 | ||
112 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); | |
113 | ||
114 | *extra = NULL; | |
115 | } | |
116 | } | |
117 | ||
118 | /* Get bgp_info extra information for the given bgp_info, lazy allocated | |
119 | * if required. | |
120 | */ | |
121 | struct bgp_info_extra * | |
122 | bgp_info_extra_get (struct bgp_info *ri) | |
123 | { | |
124 | if (!ri->extra) | |
125 | ri->extra = bgp_info_extra_new(); | |
126 | return ri->extra; | |
127 | } | |
128 | ||
718e3744 | 129 | /* Allocate new bgp info structure. */ |
200df115 | 130 | static struct bgp_info * |
66e5cd87 | 131 | bgp_info_new (void) |
718e3744 | 132 | { |
393deb9b | 133 | return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
718e3744 | 134 | } |
135 | ||
136 | /* Free bgp route information. */ | |
200df115 | 137 | static void |
718e3744 | 138 | bgp_info_free (struct bgp_info *binfo) |
139 | { | |
140 | if (binfo->attr) | |
f6f434b2 | 141 | bgp_attr_unintern (&binfo->attr); |
fb982c25 PJ |
142 | |
143 | bgp_info_extra_free (&binfo->extra); | |
de8d5dff | 144 | bgp_info_mpath_free (&binfo->mpath); |
718e3744 | 145 | |
200df115 | 146 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
147 | ||
718e3744 | 148 | XFREE (MTYPE_BGP_ROUTE, binfo); |
149 | } | |
150 | ||
200df115 | 151 | struct bgp_info * |
152 | bgp_info_lock (struct bgp_info *binfo) | |
153 | { | |
154 | binfo->lock++; | |
155 | return binfo; | |
156 | } | |
157 | ||
158 | struct bgp_info * | |
159 | bgp_info_unlock (struct bgp_info *binfo) | |
160 | { | |
161 | assert (binfo && binfo->lock > 0); | |
162 | binfo->lock--; | |
163 | ||
164 | if (binfo->lock == 0) | |
165 | { | |
166 | #if 0 | |
167 | zlog_debug ("%s: unlocked and freeing", __func__); | |
168 | zlog_backtrace (LOG_DEBUG); | |
169 | #endif | |
170 | bgp_info_free (binfo); | |
171 | return NULL; | |
172 | } | |
173 | ||
174 | #if 0 | |
175 | if (binfo->lock == 1) | |
176 | { | |
177 | zlog_debug ("%s: unlocked to 1", __func__); | |
178 | zlog_backtrace (LOG_DEBUG); | |
179 | } | |
180 | #endif | |
181 | ||
182 | return binfo; | |
183 | } | |
184 | ||
718e3744 | 185 | void |
186 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) | |
187 | { | |
188 | struct bgp_info *top; | |
189 | ||
190 | top = rn->info; | |
200df115 | 191 | |
718e3744 | 192 | ri->next = rn->info; |
193 | ri->prev = NULL; | |
194 | if (top) | |
195 | top->prev = ri; | |
196 | rn->info = ri; | |
200df115 | 197 | |
198 | bgp_info_lock (ri); | |
199 | bgp_lock_node (rn); | |
200 | peer_lock (ri->peer); /* bgp_info peer reference */ | |
718e3744 | 201 | } |
202 | ||
b40d939b | 203 | /* Do the actual removal of info from RIB, for use by bgp_process |
204 | completion callback *only* */ | |
205 | static void | |
206 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) | |
718e3744 | 207 | { |
208 | if (ri->next) | |
209 | ri->next->prev = ri->prev; | |
210 | if (ri->prev) | |
211 | ri->prev->next = ri->next; | |
212 | else | |
213 | rn->info = ri->next; | |
200df115 | 214 | |
de8d5dff | 215 | bgp_info_mpath_dequeue (ri); |
200df115 | 216 | bgp_info_unlock (ri); |
217 | bgp_unlock_node (rn); | |
718e3744 | 218 | } |
219 | ||
b40d939b | 220 | void |
221 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) | |
222 | { | |
1a392d46 PJ |
223 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
224 | /* set of previous already took care of pcount */ | |
b40d939b | 225 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
226 | } | |
227 | ||
8d45210e AS |
228 | /* undo the effects of a previous call to bgp_info_delete; typically |
229 | called when a route is deleted and then quickly re-added before the | |
230 | deletion has been processed */ | |
231 | static void | |
232 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) | |
233 | { | |
234 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); | |
235 | /* unset of previous already took care of pcount */ | |
236 | SET_FLAG (ri->flags, BGP_INFO_VALID); | |
237 | } | |
238 | ||
1a392d46 PJ |
239 | /* Adjust pcount as required */ |
240 | static void | |
241 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) | |
242 | { | |
6f58544d PJ |
243 | assert (rn && rn->table); |
244 | assert (ri && ri->peer && ri->peer->bgp); | |
245 | ||
1a392d46 PJ |
246 | /* Ignore 'pcount' for RS-client tables */ |
247 | if (rn->table->type != BGP_TABLE_MAIN | |
248 | || ri->peer == ri->peer->bgp->peer_self) | |
249 | return; | |
250 | ||
251 | if (BGP_INFO_HOLDDOWN (ri) | |
252 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
253 | { | |
254 | ||
255 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
256 | ||
257 | /* slight hack, but more robust against errors. */ | |
258 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) | |
259 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; | |
260 | else | |
261 | { | |
262 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", | |
263 | __func__, ri->peer->host); | |
264 | zlog_backtrace (LOG_WARNING); | |
265 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); | |
266 | } | |
267 | } | |
268 | else if (!BGP_INFO_HOLDDOWN (ri) | |
269 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
270 | { | |
271 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
272 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; | |
273 | } | |
274 | } | |
275 | ||
276 | ||
277 | /* Set/unset bgp_info flags, adjusting any other state as needed. | |
278 | * This is here primarily to keep prefix-count in check. | |
279 | */ | |
280 | void | |
281 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
282 | { | |
283 | SET_FLAG (ri->flags, flag); | |
284 | ||
285 | /* early bath if we know it's not a flag that changes useability state */ | |
286 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) | |
287 | return; | |
288 | ||
289 | bgp_pcount_adjust (rn, ri); | |
290 | } | |
291 | ||
292 | void | |
293 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
294 | { | |
295 | UNSET_FLAG (ri->flags, flag); | |
296 | ||
297 | /* early bath if we know it's not a flag that changes useability state */ | |
298 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) | |
299 | return; | |
300 | ||
301 | bgp_pcount_adjust (rn, ri); | |
302 | } | |
303 | ||
718e3744 | 304 | /* Get MED value. If MED value is missing and "bgp bestpath |
305 | missing-as-worst" is specified, treat it as the worst value. */ | |
94f2b392 | 306 | static u_int32_t |
718e3744 | 307 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
308 | { | |
309 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
310 | return attr->med; | |
311 | else | |
312 | { | |
313 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
3b424979 | 314 | return BGP_MED_MAX; |
718e3744 | 315 | else |
316 | return 0; | |
317 | } | |
318 | } | |
319 | ||
320 | /* Compare two bgp route entity. br is preferable then return 1. */ | |
94f2b392 | 321 | static int |
96450faf JB |
322 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
323 | int *paths_eq) | |
718e3744 | 324 | { |
8ff56318 JBD |
325 | struct attr *newattr, *existattr; |
326 | struct attr_extra *newattre, *existattre; | |
327 | bgp_peer_sort_t new_sort; | |
328 | bgp_peer_sort_t exist_sort; | |
718e3744 | 329 | u_int32_t new_pref; |
330 | u_int32_t exist_pref; | |
331 | u_int32_t new_med; | |
332 | u_int32_t exist_med; | |
8ff56318 JBD |
333 | u_int32_t new_weight; |
334 | u_int32_t exist_weight; | |
335 | uint32_t newm, existm; | |
718e3744 | 336 | struct in_addr new_id; |
337 | struct in_addr exist_id; | |
338 | int new_cluster; | |
339 | int exist_cluster; | |
8ff56318 JBD |
340 | int internal_as_route; |
341 | int confed_as_route; | |
718e3744 | 342 | int ret; |
96450faf JB |
343 | |
344 | *paths_eq = 0; | |
718e3744 | 345 | |
346 | /* 0. Null check. */ | |
347 | if (new == NULL) | |
348 | return 0; | |
349 | if (exist == NULL) | |
350 | return 1; | |
351 | ||
8ff56318 JBD |
352 | newattr = new->attr; |
353 | existattr = exist->attr; | |
354 | newattre = newattr->extra; | |
355 | existattre = existattr->extra; | |
356 | ||
718e3744 | 357 | /* 1. Weight check. */ |
8ff56318 JBD |
358 | new_weight = exist_weight = 0; |
359 | ||
360 | if (newattre) | |
361 | new_weight = newattre->weight; | |
362 | if (existattre) | |
363 | exist_weight = existattre->weight; | |
364 | ||
fb982c25 | 365 | if (new_weight > exist_weight) |
718e3744 | 366 | return 1; |
fb982c25 | 367 | if (new_weight < exist_weight) |
718e3744 | 368 | return 0; |
369 | ||
370 | /* 2. Local preference check. */ | |
8ff56318 JBD |
371 | new_pref = exist_pref = bgp->default_local_pref; |
372 | ||
373 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
374 | new_pref = newattr->local_pref; | |
375 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
376 | exist_pref = existattr->local_pref; | |
718e3744 | 377 | |
718e3744 | 378 | if (new_pref > exist_pref) |
379 | return 1; | |
380 | if (new_pref < exist_pref) | |
381 | return 0; | |
382 | ||
8ff56318 JBD |
383 | /* 3. Local route check. We prefer: |
384 | * - BGP_ROUTE_STATIC | |
385 | * - BGP_ROUTE_AGGREGATE | |
386 | * - BGP_ROUTE_REDISTRIBUTE | |
387 | */ | |
388 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) | |
389 | return 1; | |
390 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) | |
391 | return 0; | |
718e3744 | 392 | |
393 | /* 4. AS path length check. */ | |
394 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) | |
395 | { | |
8ff56318 JBD |
396 | int exist_hops = aspath_count_hops (existattr->aspath); |
397 | int exist_confeds = aspath_count_confeds (existattr->aspath); | |
fe69a505 | 398 | |
6811845b | 399 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
400 | { | |
fe69a505 | 401 | int aspath_hops; |
402 | ||
8ff56318 JBD |
403 | aspath_hops = aspath_count_hops (newattr->aspath); |
404 | aspath_hops += aspath_count_confeds (newattr->aspath); | |
fe69a505 | 405 | |
406 | if ( aspath_hops < (exist_hops + exist_confeds)) | |
6811845b | 407 | return 1; |
fe69a505 | 408 | if ( aspath_hops > (exist_hops + exist_confeds)) |
6811845b | 409 | return 0; |
410 | } | |
411 | else | |
412 | { | |
8ff56318 | 413 | int newhops = aspath_count_hops (newattr->aspath); |
fe69a505 | 414 | |
415 | if (newhops < exist_hops) | |
6811845b | 416 | return 1; |
fe69a505 | 417 | if (newhops > exist_hops) |
6811845b | 418 | return 0; |
419 | } | |
718e3744 | 420 | } |
421 | ||
422 | /* 5. Origin check. */ | |
8ff56318 | 423 | if (newattr->origin < existattr->origin) |
718e3744 | 424 | return 1; |
8ff56318 | 425 | if (newattr->origin > existattr->origin) |
718e3744 | 426 | return 0; |
427 | ||
428 | /* 6. MED check. */ | |
8ff56318 JBD |
429 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
430 | && aspath_count_hops (existattr->aspath) == 0); | |
431 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 | |
432 | && aspath_count_confeds (existattr->aspath) > 0 | |
433 | && aspath_count_hops (newattr->aspath) == 0 | |
434 | && aspath_count_hops (existattr->aspath) == 0); | |
718e3744 | 435 | |
436 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) | |
437 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) | |
438 | && confed_as_route) | |
8ff56318 JBD |
439 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
440 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) | |
718e3744 | 441 | || internal_as_route) |
442 | { | |
443 | new_med = bgp_med_value (new->attr, bgp); | |
444 | exist_med = bgp_med_value (exist->attr, bgp); | |
445 | ||
446 | if (new_med < exist_med) | |
447 | return 1; | |
448 | if (new_med > exist_med) | |
449 | return 0; | |
450 | } | |
451 | ||
452 | /* 7. Peer type check. */ | |
8ff56318 JBD |
453 | new_sort = new->peer->sort; |
454 | exist_sort = exist->peer->sort; | |
455 | ||
456 | if (new_sort == BGP_PEER_EBGP | |
457 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) | |
718e3744 | 458 | return 1; |
8ff56318 JBD |
459 | if (exist_sort == BGP_PEER_EBGP |
460 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) | |
718e3744 | 461 | return 0; |
462 | ||
463 | /* 8. IGP metric check. */ | |
8ff56318 JBD |
464 | newm = existm = 0; |
465 | ||
466 | if (new->extra) | |
467 | newm = new->extra->igpmetric; | |
468 | if (exist->extra) | |
469 | existm = exist->extra->igpmetric; | |
470 | ||
96450faf JB |
471 | if (newm < existm) |
472 | ret = 1; | |
473 | if (newm > existm) | |
474 | ret = 0; | |
718e3744 | 475 | |
476 | /* 9. Maximum path check. */ | |
96450faf JB |
477 | if (newm == existm) |
478 | { | |
6d85b15b | 479 | if (new->peer->sort == BGP_PEER_IBGP) |
96450faf JB |
480 | { |
481 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) | |
482 | *paths_eq = 1; | |
483 | } | |
484 | else if (new->peer->as == exist->peer->as) | |
485 | *paths_eq = 1; | |
486 | } | |
487 | else | |
488 | { | |
489 | /* | |
490 | * TODO: If unequal cost ibgp multipath is enabled we can | |
491 | * mark the paths as equal here instead of returning | |
492 | */ | |
493 | return ret; | |
494 | } | |
718e3744 | 495 | |
496 | /* 10. If both paths are external, prefer the path that was received | |
497 | first (the oldest one). This step minimizes route-flap, since a | |
498 | newer path won't displace an older one, even if it was the | |
499 | preferred route based on the additional decision criteria below. */ | |
500 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) | |
8ff56318 JBD |
501 | && new_sort == BGP_PEER_EBGP |
502 | && exist_sort == BGP_PEER_EBGP) | |
718e3744 | 503 | { |
504 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) | |
505 | return 1; | |
506 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) | |
507 | return 0; | |
508 | } | |
509 | ||
510 | /* 11. Rourter-ID comparision. */ | |
8ff56318 JBD |
511 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
512 | new_id.s_addr = newattre->originator_id.s_addr; | |
718e3744 | 513 | else |
514 | new_id.s_addr = new->peer->remote_id.s_addr; | |
8ff56318 JBD |
515 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
516 | exist_id.s_addr = existattre->originator_id.s_addr; | |
718e3744 | 517 | else |
518 | exist_id.s_addr = exist->peer->remote_id.s_addr; | |
519 | ||
520 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) | |
521 | return 1; | |
522 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) | |
523 | return 0; | |
524 | ||
525 | /* 12. Cluster length comparision. */ | |
8ff56318 JBD |
526 | new_cluster = exist_cluster = 0; |
527 | ||
528 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
529 | new_cluster = newattre->cluster->length; | |
530 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
531 | exist_cluster = existattre->cluster->length; | |
718e3744 | 532 | |
533 | if (new_cluster < exist_cluster) | |
534 | return 1; | |
535 | if (new_cluster > exist_cluster) | |
536 | return 0; | |
537 | ||
538 | /* 13. Neighbor address comparision. */ | |
539 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); | |
540 | ||
541 | if (ret == 1) | |
542 | return 0; | |
543 | if (ret == -1) | |
544 | return 1; | |
545 | ||
546 | return 1; | |
547 | } | |
548 | ||
94f2b392 | 549 | static enum filter_type |
718e3744 | 550 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
551 | afi_t afi, safi_t safi) | |
552 | { | |
553 | struct bgp_filter *filter; | |
554 | ||
555 | filter = &peer->filter[afi][safi]; | |
556 | ||
650f76c2 PJ |
557 | #define FILTER_EXIST_WARN(F,f,filter) \ |
558 | if (BGP_DEBUG (update, UPDATE_IN) \ | |
559 | && !(F ## _IN (filter))) \ | |
560 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ | |
561 | peer->host, #f, F ## _IN_NAME(filter)); | |
562 | ||
563 | if (DISTRIBUTE_IN_NAME (filter)) { | |
564 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
565 | ||
718e3744 | 566 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
567 | return FILTER_DENY; | |
650f76c2 | 568 | } |
718e3744 | 569 | |
650f76c2 PJ |
570 | if (PREFIX_LIST_IN_NAME (filter)) { |
571 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
572 | ||
718e3744 | 573 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
574 | return FILTER_DENY; | |
650f76c2 | 575 | } |
718e3744 | 576 | |
650f76c2 PJ |
577 | if (FILTER_LIST_IN_NAME (filter)) { |
578 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
579 | ||
718e3744 | 580 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
581 | return FILTER_DENY; | |
650f76c2 PJ |
582 | } |
583 | ||
718e3744 | 584 | return FILTER_PERMIT; |
650f76c2 | 585 | #undef FILTER_EXIST_WARN |
718e3744 | 586 | } |
587 | ||
94f2b392 | 588 | static enum filter_type |
718e3744 | 589 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
590 | afi_t afi, safi_t safi) | |
591 | { | |
592 | struct bgp_filter *filter; | |
593 | ||
594 | filter = &peer->filter[afi][safi]; | |
595 | ||
650f76c2 PJ |
596 | #define FILTER_EXIST_WARN(F,f,filter) \ |
597 | if (BGP_DEBUG (update, UPDATE_OUT) \ | |
598 | && !(F ## _OUT (filter))) \ | |
599 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ | |
600 | peer->host, #f, F ## _OUT_NAME(filter)); | |
601 | ||
602 | if (DISTRIBUTE_OUT_NAME (filter)) { | |
603 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
604 | ||
718e3744 | 605 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
606 | return FILTER_DENY; | |
650f76c2 | 607 | } |
718e3744 | 608 | |
650f76c2 PJ |
609 | if (PREFIX_LIST_OUT_NAME (filter)) { |
610 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
611 | ||
718e3744 | 612 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
613 | return FILTER_DENY; | |
650f76c2 | 614 | } |
718e3744 | 615 | |
650f76c2 PJ |
616 | if (FILTER_LIST_OUT_NAME (filter)) { |
617 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
618 | ||
718e3744 | 619 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
620 | return FILTER_DENY; | |
650f76c2 | 621 | } |
718e3744 | 622 | |
623 | return FILTER_PERMIT; | |
650f76c2 | 624 | #undef FILTER_EXIST_WARN |
718e3744 | 625 | } |
626 | ||
627 | /* If community attribute includes no_export then return 1. */ | |
94f2b392 | 628 | static int |
718e3744 | 629 | bgp_community_filter (struct peer *peer, struct attr *attr) |
630 | { | |
631 | if (attr->community) | |
632 | { | |
633 | /* NO_ADVERTISE check. */ | |
634 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) | |
635 | return 1; | |
636 | ||
637 | /* NO_EXPORT check. */ | |
6d85b15b | 638 | if (peer->sort == BGP_PEER_EBGP && |
718e3744 | 639 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
640 | return 1; | |
641 | ||
642 | /* NO_EXPORT_SUBCONFED check. */ | |
6d85b15b JBD |
643 | if (peer->sort == BGP_PEER_EBGP |
644 | || peer->sort == BGP_PEER_CONFED) | |
718e3744 | 645 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
646 | return 1; | |
647 | } | |
648 | return 0; | |
649 | } | |
650 | ||
651 | /* Route reflection loop check. */ | |
652 | static int | |
653 | bgp_cluster_filter (struct peer *peer, struct attr *attr) | |
654 | { | |
655 | struct in_addr cluster_id; | |
656 | ||
fb982c25 | 657 | if (attr->extra && attr->extra->cluster) |
718e3744 | 658 | { |
659 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) | |
660 | cluster_id = peer->bgp->cluster_id; | |
661 | else | |
662 | cluster_id = peer->bgp->router_id; | |
663 | ||
fb982c25 | 664 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
718e3744 | 665 | return 1; |
666 | } | |
667 | return 0; | |
668 | } | |
669 | \f | |
94f2b392 | 670 | static int |
718e3744 | 671 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
672 | afi_t afi, safi_t safi) | |
673 | { | |
674 | struct bgp_filter *filter; | |
675 | struct bgp_info info; | |
676 | route_map_result_t ret; | |
677 | ||
678 | filter = &peer->filter[afi][safi]; | |
679 | ||
680 | /* Apply default weight value. */ | |
fb982c25 PJ |
681 | if (peer->weight) |
682 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
718e3744 | 683 | |
684 | /* Route map apply. */ | |
685 | if (ROUTE_MAP_IN_NAME (filter)) | |
686 | { | |
687 | /* Duplicate current value to new strucutre for modification. */ | |
688 | info.peer = peer; | |
689 | info.attr = attr; | |
690 | ||
ac41b2a2 | 691 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
692 | ||
718e3744 | 693 | /* Apply BGP route map to the attribute. */ |
694 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); | |
ac41b2a2 | 695 | |
696 | peer->rmap_type = 0; | |
697 | ||
718e3744 | 698 | if (ret == RMAP_DENYMATCH) |
699 | { | |
700 | /* Free newly generated AS path and community by route-map. */ | |
701 | bgp_attr_flush (attr); | |
702 | return RMAP_DENY; | |
703 | } | |
704 | } | |
705 | return RMAP_PERMIT; | |
706 | } | |
707 | \f | |
94f2b392 | 708 | static int |
fee0f4c6 | 709 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
710 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
711 | { | |
712 | struct bgp_filter *filter; | |
713 | struct bgp_info info; | |
714 | route_map_result_t ret; | |
715 | ||
716 | filter = &peer->filter[afi][safi]; | |
717 | ||
718 | /* Route map apply. */ | |
719 | if (ROUTE_MAP_EXPORT_NAME (filter)) | |
720 | { | |
721 | /* Duplicate current value to new strucutre for modification. */ | |
722 | info.peer = rsclient; | |
723 | info.attr = attr; | |
724 | ||
725 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); | |
726 | ||
727 | /* Apply BGP route map to the attribute. */ | |
728 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); | |
729 | ||
730 | rsclient->rmap_type = 0; | |
731 | ||
732 | if (ret == RMAP_DENYMATCH) | |
733 | { | |
734 | /* Free newly generated AS path and community by route-map. */ | |
735 | bgp_attr_flush (attr); | |
736 | return RMAP_DENY; | |
737 | } | |
738 | } | |
739 | return RMAP_PERMIT; | |
740 | } | |
741 | ||
94f2b392 | 742 | static int |
fee0f4c6 | 743 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
744 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
745 | { | |
746 | struct bgp_filter *filter; | |
747 | struct bgp_info info; | |
748 | route_map_result_t ret; | |
749 | ||
750 | filter = &rsclient->filter[afi][safi]; | |
751 | ||
752 | /* Apply default weight value. */ | |
fb982c25 PJ |
753 | if (peer->weight) |
754 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
fee0f4c6 | 755 | |
756 | /* Route map apply. */ | |
757 | if (ROUTE_MAP_IMPORT_NAME (filter)) | |
758 | { | |
759 | /* Duplicate current value to new strucutre for modification. */ | |
760 | info.peer = peer; | |
761 | info.attr = attr; | |
762 | ||
763 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); | |
764 | ||
765 | /* Apply BGP route map to the attribute. */ | |
766 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); | |
767 | ||
768 | peer->rmap_type = 0; | |
769 | ||
770 | if (ret == RMAP_DENYMATCH) | |
771 | { | |
772 | /* Free newly generated AS path and community by route-map. */ | |
773 | bgp_attr_flush (attr); | |
774 | return RMAP_DENY; | |
775 | } | |
776 | } | |
777 | return RMAP_PERMIT; | |
778 | } | |
779 | \f | |
94f2b392 | 780 | static int |
718e3744 | 781 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
782 | struct attr *attr, afi_t afi, safi_t safi) | |
783 | { | |
784 | int ret; | |
785 | char buf[SU_ADDRSTRLEN]; | |
786 | struct bgp_filter *filter; | |
718e3744 | 787 | struct peer *from; |
788 | struct bgp *bgp; | |
718e3744 | 789 | int transparent; |
790 | int reflect; | |
0b597ef0 | 791 | struct attr *riattr; |
718e3744 | 792 | |
793 | from = ri->peer; | |
794 | filter = &peer->filter[afi][safi]; | |
795 | bgp = peer->bgp; | |
0b597ef0 | 796 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
718e3744 | 797 | |
750e8146 PJ |
798 | if (DISABLE_BGP_ANNOUNCE) |
799 | return 0; | |
718e3744 | 800 | |
fee0f4c6 | 801 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
802 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
803 | return 0; | |
804 | ||
718e3744 | 805 | /* Do not send back route to sender. */ |
806 | if (from == peer) | |
807 | return 0; | |
808 | ||
35be31b6 | 809 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
810 | if (p->family == AF_INET | |
0b597ef0 | 811 | && IPV4_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
35be31b6 | 812 | return 0; |
813 | #ifdef HAVE_IPV6 | |
814 | if (p->family == AF_INET6 | |
0b597ef0 | 815 | && IPV6_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
35be31b6 | 816 | return 0; |
817 | #endif | |
818 | ||
718e3744 | 819 | /* Aggregate-address suppress check. */ |
fb982c25 | 820 | if (ri->extra && ri->extra->suppress) |
718e3744 | 821 | if (! UNSUPPRESS_MAP_NAME (filter)) |
822 | return 0; | |
823 | ||
824 | /* Default route check. */ | |
825 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
826 | { | |
827 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
828 | return 0; | |
829 | #ifdef HAVE_IPV6 | |
830 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
831 | return 0; | |
832 | #endif /* HAVE_IPV6 */ | |
833 | } | |
834 | ||
286e1e71 | 835 | /* Transparency check. */ |
836 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) | |
837 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
838 | transparent = 1; | |
839 | else | |
840 | transparent = 0; | |
841 | ||
718e3744 | 842 | /* If community is not disabled check the no-export and local. */ |
0b597ef0 | 843 | if (! transparent && bgp_community_filter (peer, riattr)) |
718e3744 | 844 | return 0; |
845 | ||
846 | /* If the attribute has originator-id and it is same as remote | |
847 | peer's id. */ | |
0b597ef0 | 848 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
718e3744 | 849 | { |
0b597ef0 | 850 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
718e3744 | 851 | { |
852 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 853 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 854 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
855 | peer->host, | |
856 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
857 | p->prefixlen); | |
858 | return 0; | |
859 | } | |
860 | } | |
861 | ||
862 | /* ORF prefix-list filter check */ | |
863 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
864 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
865 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
866 | if (peer->orf_plist[afi][safi]) | |
867 | { | |
868 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) | |
869 | return 0; | |
870 | } | |
871 | ||
872 | /* Output filter check. */ | |
0b597ef0 | 873 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
718e3744 | 874 | { |
875 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 876 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 877 | "%s [Update:SEND] %s/%d is filtered", |
878 | peer->host, | |
879 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
880 | p->prefixlen); | |
881 | return 0; | |
882 | } | |
883 | ||
884 | #ifdef BGP_SEND_ASPATH_CHECK | |
885 | /* AS path loop check. */ | |
0b597ef0 | 886 | if (aspath_loop_check (riattr->aspath, peer->as)) |
718e3744 | 887 | { |
888 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 889 | zlog (peer->log, LOG_DEBUG, |
aea339f7 | 890 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
718e3744 | 891 | peer->host, peer->as); |
892 | return 0; | |
893 | } | |
894 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
895 | ||
896 | /* If we're a CONFED we need to loop check the CONFED ID too */ | |
897 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
898 | { | |
0b597ef0 | 899 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
718e3744 | 900 | { |
901 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 902 | zlog (peer->log, LOG_DEBUG, |
aea339f7 | 903 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
718e3744 | 904 | peer->host, |
905 | bgp->confed_id); | |
906 | return 0; | |
907 | } | |
908 | } | |
909 | ||
910 | /* Route-Reflect check. */ | |
6d85b15b | 911 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
718e3744 | 912 | reflect = 1; |
913 | else | |
914 | reflect = 0; | |
915 | ||
916 | /* IBGP reflection check. */ | |
917 | if (reflect) | |
918 | { | |
919 | /* A route from a Client peer. */ | |
920 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
921 | { | |
922 | /* Reflect to all the Non-Client peers and also to the | |
923 | Client peers other than the originator. Originator check | |
924 | is already done. So there is noting to do. */ | |
925 | /* no bgp client-to-client reflection check. */ | |
926 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
927 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
928 | return 0; | |
929 | } | |
930 | else | |
931 | { | |
932 | /* A route from a Non-client peer. Reflect to all other | |
933 | clients. */ | |
934 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
935 | return 0; | |
936 | } | |
937 | } | |
41367172 | 938 | |
718e3744 | 939 | /* For modify attribute, copy it to temporary structure. */ |
0b597ef0 | 940 | bgp_attr_dup (attr, riattr); |
fb982c25 | 941 | |
718e3744 | 942 | /* If local-preference is not set. */ |
6d85b15b JBD |
943 | if ((peer->sort == BGP_PEER_IBGP |
944 | || peer->sort == BGP_PEER_CONFED) | |
718e3744 | 945 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
946 | { | |
947 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
948 | attr->local_pref = bgp->default_local_pref; | |
949 | } | |
950 | ||
718e3744 | 951 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
6d85b15b | 952 | if (peer->sort == BGP_PEER_EBGP |
718e3744 | 953 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
954 | { | |
955 | if (ri->peer != bgp->peer_self && ! transparent | |
956 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
957 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
958 | } | |
959 | ||
960 | /* next-hop-set */ | |
961 | if (transparent || reflect | |
962 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) | |
963 | && ((p->family == AF_INET && attr->nexthop.s_addr) | |
286e1e71 | 964 | #ifdef HAVE_IPV6 |
fee0f4c6 | 965 | || (p->family == AF_INET6 && |
fb982c25 | 966 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
286e1e71 | 967 | #endif /* HAVE_IPV6 */ |
968 | ))) | |
718e3744 | 969 | { |
970 | /* NEXT-HOP Unchanged. */ | |
971 | } | |
972 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
973 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) | |
974 | #ifdef HAVE_IPV6 | |
fee0f4c6 | 975 | || (p->family == AF_INET6 && |
fb982c25 | 976 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
718e3744 | 977 | #endif /* HAVE_IPV6 */ |
6d85b15b | 978 | || (peer->sort == BGP_PEER_EBGP |
718e3744 | 979 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
980 | { | |
981 | /* Set IPv4 nexthop. */ | |
982 | if (p->family == AF_INET) | |
983 | { | |
984 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
985 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
986 | IPV4_MAX_BYTELEN); | |
718e3744 | 987 | else |
988 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
989 | } | |
990 | #ifdef HAVE_IPV6 | |
991 | /* Set IPv6 nexthop. */ | |
992 | if (p->family == AF_INET6) | |
993 | { | |
994 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 995 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 996 | IPV6_MAX_BYTELEN); |
fb982c25 | 997 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 998 | } |
999 | #endif /* HAVE_IPV6 */ | |
1000 | } | |
1001 | ||
1002 | #ifdef HAVE_IPV6 | |
1003 | if (p->family == AF_INET6) | |
1004 | { | |
fee0f4c6 | 1005 | /* Left nexthop_local unchanged if so configured. */ |
1006 | if ( CHECK_FLAG (peer->af_flags[afi][safi], | |
1007 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
1008 | { | |
fb982c25 PJ |
1009 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
1010 | attr->extra->mp_nexthop_len=32; | |
fee0f4c6 | 1011 | else |
fb982c25 | 1012 | attr->extra->mp_nexthop_len=16; |
fee0f4c6 | 1013 | } |
1014 | ||
1015 | /* Default nexthop_local treatment for non-RS-Clients */ | |
1016 | else | |
1017 | { | |
718e3744 | 1018 | /* Link-local address should not be transit to different peer. */ |
fb982c25 | 1019 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1020 | |
1021 | /* Set link-local address for shared network peer. */ | |
1022 | if (peer->shared_network | |
1023 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
1024 | { | |
fb982c25 | 1025 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 1026 | IPV6_MAX_BYTELEN); |
fb982c25 | 1027 | attr->extra->mp_nexthop_len = 32; |
718e3744 | 1028 | } |
1029 | ||
1030 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local | |
1031 | address.*/ | |
1032 | if (reflect) | |
fb982c25 | 1033 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1034 | |
1035 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ | |
1036 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) | |
fb982c25 | 1037 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1038 | } |
fee0f4c6 | 1039 | |
1040 | } | |
718e3744 | 1041 | #endif /* HAVE_IPV6 */ |
1042 | ||
1043 | /* If this is EBGP peer and remove-private-AS is set. */ | |
6d85b15b | 1044 | if (peer->sort == BGP_PEER_EBGP |
718e3744 | 1045 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
1046 | && aspath_private_as_check (attr->aspath)) | |
1047 | attr->aspath = aspath_empty_get (); | |
1048 | ||
1049 | /* Route map & unsuppress-map apply. */ | |
1050 | if (ROUTE_MAP_OUT_NAME (filter) | |
fb982c25 | 1051 | || (ri->extra && ri->extra->suppress) ) |
718e3744 | 1052 | { |
7c7fa1b4 | 1053 | struct bgp_info info; |
9eda90ce | 1054 | struct attr dummy_attr = { 0 }; |
7c7fa1b4 | 1055 | |
718e3744 | 1056 | info.peer = peer; |
1057 | info.attr = attr; | |
1058 | ||
1059 | /* The route reflector is not allowed to modify the attributes | |
1060 | of the reflected IBGP routes. */ | |
6d85b15b JBD |
1061 | if (from->sort == BGP_PEER_IBGP |
1062 | && peer->sort == BGP_PEER_IBGP) | |
718e3744 | 1063 | { |
fb982c25 | 1064 | bgp_attr_dup (&dummy_attr, attr); |
9eda90ce | 1065 | info.attr = &dummy_attr; |
718e3744 | 1066 | } |
ac41b2a2 | 1067 | |
1068 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1069 | ||
fb982c25 | 1070 | if (ri->extra && ri->extra->suppress) |
718e3744 | 1071 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1072 | else | |
1073 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1074 | ||
ac41b2a2 | 1075 | peer->rmap_type = 0; |
fb982c25 | 1076 | |
9eda90ce PJ |
1077 | if (dummy_attr.extra) |
1078 | bgp_attr_extra_free (&dummy_attr); | |
fb982c25 | 1079 | |
718e3744 | 1080 | if (ret == RMAP_DENYMATCH) |
1081 | { | |
1082 | bgp_attr_flush (attr); | |
1083 | return 0; | |
1084 | } | |
1085 | } | |
1086 | return 1; | |
1087 | } | |
1088 | ||
94f2b392 | 1089 | static int |
fee0f4c6 | 1090 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
1091 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
1092 | { | |
1093 | int ret; | |
1094 | char buf[SU_ADDRSTRLEN]; | |
1095 | struct bgp_filter *filter; | |
1096 | struct bgp_info info; | |
1097 | struct peer *from; | |
0b597ef0 | 1098 | struct attr *riattr; |
fee0f4c6 | 1099 | |
1100 | from = ri->peer; | |
1101 | filter = &rsclient->filter[afi][safi]; | |
0b597ef0 | 1102 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
fee0f4c6 | 1103 | |
750e8146 PJ |
1104 | if (DISABLE_BGP_ANNOUNCE) |
1105 | return 0; | |
fee0f4c6 | 1106 | |
1107 | /* Do not send back route to sender. */ | |
1108 | if (from == rsclient) | |
1109 | return 0; | |
1110 | ||
1111 | /* Aggregate-address suppress check. */ | |
fb982c25 | 1112 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1113 | if (! UNSUPPRESS_MAP_NAME (filter)) |
1114 | return 0; | |
1115 | ||
1116 | /* Default route check. */ | |
1117 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], | |
1118 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
1119 | { | |
1120 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1121 | return 0; | |
1122 | #ifdef HAVE_IPV6 | |
1123 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1124 | return 0; | |
1125 | #endif /* HAVE_IPV6 */ | |
1126 | } | |
1127 | ||
1128 | /* If the attribute has originator-id and it is same as remote | |
1129 | peer's id. */ | |
0b597ef0 | 1130 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
fee0f4c6 | 1131 | { |
fb982c25 | 1132 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
0b597ef0 | 1133 | &riattr->extra->originator_id)) |
fee0f4c6 | 1134 | { |
1135 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1136 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1137 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
1138 | rsclient->host, | |
1139 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1140 | p->prefixlen); | |
1141 | return 0; | |
1142 | } | |
1143 | } | |
1144 | ||
1145 | /* ORF prefix-list filter check */ | |
1146 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1147 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1148 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1149 | if (rsclient->orf_plist[afi][safi]) | |
1150 | { | |
1151 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1152 | return 0; | |
1153 | } | |
1154 | ||
1155 | /* Output filter check. */ | |
0b597ef0 | 1156 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
fee0f4c6 | 1157 | { |
1158 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1159 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1160 | "%s [Update:SEND] %s/%d is filtered", |
1161 | rsclient->host, | |
1162 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1163 | p->prefixlen); | |
1164 | return 0; | |
1165 | } | |
1166 | ||
1167 | #ifdef BGP_SEND_ASPATH_CHECK | |
1168 | /* AS path loop check. */ | |
0b597ef0 | 1169 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
fee0f4c6 | 1170 | { |
1171 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1172 | zlog (rsclient->log, LOG_DEBUG, |
aea339f7 | 1173 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
fee0f4c6 | 1174 | rsclient->host, rsclient->as); |
1175 | return 0; | |
1176 | } | |
1177 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1178 | ||
1179 | /* For modify attribute, copy it to temporary structure. */ | |
0b597ef0 | 1180 | bgp_attr_dup (attr, riattr); |
fee0f4c6 | 1181 | |
1182 | /* next-hop-set */ | |
1183 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) | |
1184 | #ifdef HAVE_IPV6 | |
1185 | || (p->family == AF_INET6 && | |
fb982c25 | 1186 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
fee0f4c6 | 1187 | #endif /* HAVE_IPV6 */ |
1188 | ) | |
1189 | { | |
1190 | /* Set IPv4 nexthop. */ | |
1191 | if (p->family == AF_INET) | |
1192 | { | |
1193 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1194 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
fee0f4c6 | 1195 | IPV4_MAX_BYTELEN); |
1196 | else | |
1197 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); | |
1198 | } | |
1199 | #ifdef HAVE_IPV6 | |
1200 | /* Set IPv6 nexthop. */ | |
1201 | if (p->family == AF_INET6) | |
1202 | { | |
1203 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 1204 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
fee0f4c6 | 1205 | IPV6_MAX_BYTELEN); |
fb982c25 | 1206 | attr->extra->mp_nexthop_len = 16; |
fee0f4c6 | 1207 | } |
1208 | #endif /* HAVE_IPV6 */ | |
1209 | } | |
1210 | ||
1211 | #ifdef HAVE_IPV6 | |
1212 | if (p->family == AF_INET6) | |
1213 | { | |
fb982c25 PJ |
1214 | struct attr_extra *attre = attr->extra; |
1215 | ||
1216 | assert (attr->extra); | |
1217 | ||
fee0f4c6 | 1218 | /* Left nexthop_local unchanged if so configured. */ |
1219 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], | |
1220 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
1221 | { | |
fb982c25 PJ |
1222 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1223 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1224 | else |
fb982c25 | 1225 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1226 | } |
1227 | ||
1228 | /* Default nexthop_local treatment for RS-Clients */ | |
1229 | else | |
1230 | { | |
1231 | /* Announcer and RS-Client are both in the same network */ | |
1232 | if (rsclient->shared_network && from->shared_network && | |
1233 | (rsclient->ifindex == from->ifindex)) | |
1234 | { | |
fb982c25 PJ |
1235 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1236 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1237 | else |
fb982c25 | 1238 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1239 | } |
1240 | ||
1241 | /* Set link-local address for shared network peer. */ | |
1242 | else if (rsclient->shared_network | |
1243 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) | |
1244 | { | |
fb982c25 | 1245 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
fee0f4c6 | 1246 | IPV6_MAX_BYTELEN); |
fb982c25 | 1247 | attre->mp_nexthop_len = 32; |
fee0f4c6 | 1248 | } |
1249 | ||
1250 | else | |
fb982c25 | 1251 | attre->mp_nexthop_len = 16; |
fee0f4c6 | 1252 | } |
1253 | ||
1254 | } | |
1255 | #endif /* HAVE_IPV6 */ | |
1256 | ||
1257 | ||
1258 | /* If this is EBGP peer and remove-private-AS is set. */ | |
6d85b15b | 1259 | if (rsclient->sort == BGP_PEER_EBGP |
fee0f4c6 | 1260 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
1261 | && aspath_private_as_check (attr->aspath)) | |
1262 | attr->aspath = aspath_empty_get (); | |
1263 | ||
1264 | /* Route map & unsuppress-map apply. */ | |
fb982c25 | 1265 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
fee0f4c6 | 1266 | { |
1267 | info.peer = rsclient; | |
1268 | info.attr = attr; | |
1269 | ||
1270 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); | |
1271 | ||
fb982c25 | 1272 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1273 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1274 | else | |
1275 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1276 | ||
1277 | rsclient->rmap_type = 0; | |
1278 | ||
1279 | if (ret == RMAP_DENYMATCH) | |
1280 | { | |
1281 | bgp_attr_flush (attr); | |
1282 | return 0; | |
1283 | } | |
1284 | } | |
1285 | ||
1286 | return 1; | |
1287 | } | |
1288 | ||
1289 | struct bgp_info_pair | |
1290 | { | |
1291 | struct bgp_info *old; | |
1292 | struct bgp_info *new; | |
1293 | }; | |
1294 | ||
94f2b392 | 1295 | static void |
96450faf JB |
1296 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
1297 | struct bgp_maxpaths_cfg *mpath_cfg, | |
1298 | struct bgp_info_pair *result) | |
718e3744 | 1299 | { |
718e3744 | 1300 | struct bgp_info *new_select; |
1301 | struct bgp_info *old_select; | |
fee0f4c6 | 1302 | struct bgp_info *ri; |
718e3744 | 1303 | struct bgp_info *ri1; |
1304 | struct bgp_info *ri2; | |
b40d939b | 1305 | struct bgp_info *nextri = NULL; |
96450faf JB |
1306 | int paths_eq, do_mpath; |
1307 | struct list mp_list; | |
1308 | ||
1309 | bgp_mp_list_init (&mp_list); | |
1310 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || | |
1311 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); | |
1312 | ||
718e3744 | 1313 | /* bgp deterministic-med */ |
1314 | new_select = NULL; | |
1315 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1316 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1317 | { | |
1318 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1319 | continue; | |
1320 | if (BGP_INFO_HOLDDOWN (ri1)) | |
1321 | continue; | |
1322 | ||
1323 | new_select = ri1; | |
6918e74b JB |
1324 | if (do_mpath) |
1325 | bgp_mp_list_add (&mp_list, ri1); | |
1326 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; | |
718e3744 | 1327 | if (ri1->next) |
1328 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1329 | { | |
1330 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1331 | continue; | |
1332 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1333 | continue; | |
1334 | ||
1335 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1336 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1337 | ri2->attr->aspath)) | |
1338 | { | |
6918e74b JB |
1339 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
1340 | old_select = ri2; | |
96450faf | 1341 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
718e3744 | 1342 | { |
1a392d46 | 1343 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
718e3744 | 1344 | new_select = ri2; |
6918e74b JB |
1345 | if (do_mpath && !paths_eq) |
1346 | { | |
1347 | bgp_mp_list_clear (&mp_list); | |
1348 | bgp_mp_list_add (&mp_list, ri2); | |
1349 | } | |
718e3744 | 1350 | } |
1351 | ||
6918e74b JB |
1352 | if (do_mpath && paths_eq) |
1353 | bgp_mp_list_add (&mp_list, ri2); | |
1354 | ||
1a392d46 | 1355 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
718e3744 | 1356 | } |
1357 | } | |
1a392d46 PJ |
1358 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
1359 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
6918e74b JB |
1360 | |
1361 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); | |
1362 | bgp_mp_list_clear (&mp_list); | |
718e3744 | 1363 | } |
1364 | ||
1365 | /* Check old selected route and new selected route. */ | |
1366 | old_select = NULL; | |
1367 | new_select = NULL; | |
b40d939b | 1368 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1369 | { |
1370 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1371 | old_select = ri; | |
1372 | ||
1373 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1374 | { |
1375 | /* reap REMOVED routes, if needs be | |
1376 | * selected route must stay for a while longer though | |
1377 | */ | |
1378 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1379 | && (ri != old_select)) | |
1380 | bgp_info_reap (rn, ri); | |
1381 | ||
1382 | continue; | |
1383 | } | |
718e3744 | 1384 | |
1385 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) | |
1386 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1387 | { | |
1a392d46 | 1388 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1389 | continue; |
1390 | } | |
1a392d46 PJ |
1391 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
1392 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1393 | |
96450faf JB |
1394 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
1395 | { | |
6918e74b JB |
1396 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1397 | bgp_mp_dmed_deselect (new_select); | |
1398 | ||
96450faf JB |
1399 | new_select = ri; |
1400 | ||
1401 | if (do_mpath && !paths_eq) | |
1402 | { | |
1403 | bgp_mp_list_clear (&mp_list); | |
1404 | bgp_mp_list_add (&mp_list, ri); | |
1405 | } | |
1406 | } | |
6918e74b JB |
1407 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1408 | bgp_mp_dmed_deselect (ri); | |
96450faf JB |
1409 | |
1410 | if (do_mpath && paths_eq) | |
1411 | bgp_mp_list_add (&mp_list, ri); | |
718e3744 | 1412 | } |
b40d939b | 1413 | |
fee0f4c6 | 1414 | |
6918e74b JB |
1415 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1416 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); | |
96450faf | 1417 | |
0b597ef0 | 1418 | bgp_info_mpath_aggregate_update (new_select, old_select); |
96450faf JB |
1419 | bgp_mp_list_clear (&mp_list); |
1420 | ||
1421 | result->old = old_select; | |
1422 | result->new = new_select; | |
1423 | ||
1424 | return; | |
fee0f4c6 | 1425 | } |
1426 | ||
94f2b392 | 1427 | static int |
fee0f4c6 | 1428 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
9eda90ce PJ |
1429 | struct bgp_node *rn, afi_t afi, safi_t safi) |
1430 | { | |
fee0f4c6 | 1431 | struct prefix *p; |
9eda90ce | 1432 | struct attr attr = { 0 }; |
fee0f4c6 | 1433 | |
1434 | p = &rn->p; | |
1435 | ||
9eda90ce PJ |
1436 | /* Announce route to Established peer. */ |
1437 | if (peer->status != Established) | |
fee0f4c6 | 1438 | return 0; |
718e3744 | 1439 | |
9eda90ce PJ |
1440 | /* Address family configuration check. */ |
1441 | if (! peer->afc_nego[afi][safi]) | |
fee0f4c6 | 1442 | return 0; |
718e3744 | 1443 | |
9eda90ce | 1444 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
fee0f4c6 | 1445 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
1446 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
1447 | return 0; | |
718e3744 | 1448 | |
fee0f4c6 | 1449 | switch (rn->table->type) |
1450 | { | |
1451 | case BGP_TABLE_MAIN: | |
718e3744 | 1452 | /* Announcement to peer->conf. If the route is filtered, |
1453 | withdraw it. */ | |
9eda90ce PJ |
1454 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
1455 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
fee0f4c6 | 1456 | else |
1457 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
1458 | break; | |
1459 | case BGP_TABLE_RSCLIENT: | |
1460 | /* Announcement to peer->conf. If the route is filtered, | |
1461 | withdraw it. */ | |
9eda90ce PJ |
1462 | if (selected && |
1463 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) | |
1464 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
1465 | else | |
1466 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
fee0f4c6 | 1467 | break; |
1468 | } | |
9eda90ce PJ |
1469 | |
1470 | bgp_attr_extra_free (&attr); | |
1471 | ||
fee0f4c6 | 1472 | return 0; |
200df115 | 1473 | } |
fee0f4c6 | 1474 | |
200df115 | 1475 | struct bgp_process_queue |
fee0f4c6 | 1476 | { |
200df115 | 1477 | struct bgp *bgp; |
1478 | struct bgp_node *rn; | |
1479 | afi_t afi; | |
1480 | safi_t safi; | |
1481 | }; | |
1482 | ||
1483 | static wq_item_status | |
0fb58d5d | 1484 | bgp_process_rsclient (struct work_queue *wq, void *data) |
200df115 | 1485 | { |
0fb58d5d | 1486 | struct bgp_process_queue *pq = data; |
200df115 | 1487 | struct bgp *bgp = pq->bgp; |
1488 | struct bgp_node *rn = pq->rn; | |
1489 | afi_t afi = pq->afi; | |
1490 | safi_t safi = pq->safi; | |
fee0f4c6 | 1491 | struct bgp_info *new_select; |
1492 | struct bgp_info *old_select; | |
1493 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1494 | struct listnode *node, *nnode; |
200df115 | 1495 | struct peer *rsclient = rn->table->owner; |
1496 | ||
fee0f4c6 | 1497 | /* Best path selection. */ |
96450faf | 1498 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1499 | new_select = old_and_new.new; |
1500 | old_select = old_and_new.old; | |
1501 | ||
200df115 | 1502 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
1503 | { | |
228da428 CC |
1504 | if (rsclient->group) |
1505 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) | |
1506 | { | |
1507 | /* Nothing to do. */ | |
1508 | if (old_select && old_select == new_select) | |
1509 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
1510 | continue; | |
1511 | ||
1512 | if (old_select) | |
1513 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); | |
1514 | if (new_select) | |
1515 | { | |
1516 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); | |
1517 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
8196f13d JB |
1518 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
1519 | } | |
228da428 CC |
1520 | |
1521 | bgp_process_announce_selected (rsclient, new_select, rn, | |
1522 | afi, safi); | |
1523 | } | |
200df115 | 1524 | } |
1525 | else | |
1526 | { | |
b7395791 | 1527 | if (old_select) |
1a392d46 | 1528 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
b7395791 | 1529 | if (new_select) |
1530 | { | |
1a392d46 PJ |
1531 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1532 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
8196f13d | 1533 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
b7395791 | 1534 | } |
9eda90ce | 1535 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
200df115 | 1536 | } |
1537 | ||
b40d939b | 1538 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1539 | bgp_info_reap (rn, old_select); | |
1540 | ||
200df115 | 1541 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1542 | return WQ_SUCCESS; | |
fee0f4c6 | 1543 | } |
1544 | ||
200df115 | 1545 | static wq_item_status |
0fb58d5d | 1546 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1547 | { |
0fb58d5d | 1548 | struct bgp_process_queue *pq = data; |
200df115 | 1549 | struct bgp *bgp = pq->bgp; |
1550 | struct bgp_node *rn = pq->rn; | |
1551 | afi_t afi = pq->afi; | |
1552 | safi_t safi = pq->safi; | |
1553 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1554 | struct bgp_info *new_select; |
1555 | struct bgp_info *old_select; | |
1556 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1557 | struct listnode *node, *nnode; |
fee0f4c6 | 1558 | struct peer *peer; |
fb982c25 | 1559 | |
fee0f4c6 | 1560 | /* Best path selection. */ |
96450faf | 1561 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1562 | old_select = old_and_new.old; |
1563 | new_select = old_and_new.new; | |
1564 | ||
1565 | /* Nothing to do. */ | |
1566 | if (old_select && old_select == new_select) | |
1567 | { | |
1568 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
200df115 | 1569 | { |
8196f13d JB |
1570 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
1571 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) | |
5a616c08 | 1572 | bgp_zebra_announce (p, old_select, bgp, safi); |
200df115 | 1573 | |
8196f13d | 1574 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
200df115 | 1575 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1576 | return WQ_SUCCESS; | |
1577 | } | |
fee0f4c6 | 1578 | } |
1579 | ||
338b3424 | 1580 | if (old_select) |
1a392d46 | 1581 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1582 | if (new_select) |
1583 | { | |
1a392d46 PJ |
1584 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1585 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
8196f13d | 1586 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
338b3424 | 1587 | } |
1588 | ||
1589 | ||
fee0f4c6 | 1590 | /* Check each BGP peer. */ |
1eb8ef25 | 1591 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
fee0f4c6 | 1592 | { |
9eda90ce | 1593 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
718e3744 | 1594 | } |
1595 | ||
1596 | /* FIB update. */ | |
5a616c08 B |
1597 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
1598 | ! bgp_option_check (BGP_OPT_NO_FIB))) | |
718e3744 | 1599 | { |
1600 | if (new_select | |
1601 | && new_select->type == ZEBRA_ROUTE_BGP | |
1602 | && new_select->sub_type == BGP_ROUTE_NORMAL) | |
5a616c08 | 1603 | bgp_zebra_announce (p, new_select, bgp, safi); |
718e3744 | 1604 | else |
1605 | { | |
1606 | /* Withdraw the route from the kernel. */ | |
1607 | if (old_select | |
1608 | && old_select->type == ZEBRA_ROUTE_BGP | |
1609 | && old_select->sub_type == BGP_ROUTE_NORMAL) | |
5a616c08 | 1610 | bgp_zebra_withdraw (p, old_select, safi); |
718e3744 | 1611 | } |
1612 | } | |
b40d939b | 1613 | |
1614 | /* Reap old select bgp_info, it it has been removed */ | |
1615 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) | |
1616 | bgp_info_reap (rn, old_select); | |
1617 | ||
200df115 | 1618 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1619 | return WQ_SUCCESS; | |
718e3744 | 1620 | } |
1621 | ||
200df115 | 1622 | static void |
0fb58d5d | 1623 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1624 | { |
0fb58d5d | 1625 | struct bgp_process_queue *pq = data; |
228da428 | 1626 | struct bgp_table *table = pq->rn->table; |
0fb58d5d | 1627 | |
228da428 | 1628 | bgp_unlock (pq->bgp); |
200df115 | 1629 | bgp_unlock_node (pq->rn); |
228da428 | 1630 | bgp_table_unlock (table); |
200df115 | 1631 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1632 | } | |
1633 | ||
1634 | static void | |
1635 | bgp_process_queue_init (void) | |
1636 | { | |
1637 | bm->process_main_queue | |
1638 | = work_queue_new (bm->master, "process_main_queue"); | |
1639 | bm->process_rsclient_queue | |
1640 | = work_queue_new (bm->master, "process_rsclient_queue"); | |
1641 | ||
1642 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) | |
1643 | { | |
1644 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1645 | exit (1); | |
1646 | } | |
1647 | ||
1648 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1649 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1650 | bm->process_main_queue->spec.max_retries = 0; |
1651 | bm->process_main_queue->spec.hold = 50; | |
1652 | ||
1653 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, | |
1654 | sizeof (struct work_queue *)); | |
1655 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; | |
200df115 | 1656 | } |
1657 | ||
1658 | void | |
fee0f4c6 | 1659 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1660 | { | |
200df115 | 1661 | struct bgp_process_queue *pqnode; |
1662 | ||
1663 | /* already scheduled for processing? */ | |
1664 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1665 | return; | |
1666 | ||
1667 | if ( (bm->process_main_queue == NULL) || | |
1668 | (bm->process_rsclient_queue == NULL) ) | |
1669 | bgp_process_queue_init (); | |
1670 | ||
1671 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, | |
1672 | sizeof (struct bgp_process_queue)); | |
1673 | if (!pqnode) | |
1674 | return; | |
228da428 CC |
1675 | |
1676 | /* all unlocked in bgp_processq_del */ | |
1677 | bgp_table_lock (rn->table); | |
1678 | pqnode->rn = bgp_lock_node (rn); | |
200df115 | 1679 | pqnode->bgp = bgp; |
228da428 | 1680 | bgp_lock (bgp); |
200df115 | 1681 | pqnode->afi = afi; |
1682 | pqnode->safi = safi; | |
1683 | ||
fee0f4c6 | 1684 | switch (rn->table->type) |
1685 | { | |
200df115 | 1686 | case BGP_TABLE_MAIN: |
1687 | work_queue_add (bm->process_main_queue, pqnode); | |
1688 | break; | |
1689 | case BGP_TABLE_RSCLIENT: | |
1690 | work_queue_add (bm->process_rsclient_queue, pqnode); | |
1691 | break; | |
fee0f4c6 | 1692 | } |
200df115 | 1693 | |
1694 | return; | |
fee0f4c6 | 1695 | } |
0a486e5f | 1696 | |
94f2b392 | 1697 | static int |
0a486e5f | 1698 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
1699 | { | |
1700 | struct peer *peer; | |
1701 | ||
1702 | peer = THREAD_ARG (thread); | |
1703 | peer->t_pmax_restart = NULL; | |
1704 | ||
1705 | if (BGP_DEBUG (events, EVENTS)) | |
1706 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", | |
1707 | peer->host); | |
1708 | ||
1709 | peer_clear (peer); | |
1710 | ||
1711 | return 0; | |
1712 | } | |
1713 | ||
718e3744 | 1714 | int |
5228ad27 | 1715 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
1716 | safi_t safi, int always) | |
718e3744 | 1717 | { |
e0701b79 | 1718 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
1719 | return 0; | |
1720 | ||
1721 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 1722 | { |
e0701b79 | 1723 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
1724 | && ! always) | |
1725 | return 0; | |
1726 | ||
1727 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1728 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
1729 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
1730 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 1731 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
1732 | ||
1733 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
1734 | return 0; | |
1735 | ||
1736 | { | |
5228ad27 | 1737 | u_int8_t ndata[7]; |
e0701b79 | 1738 | |
1739 | if (safi == SAFI_MPLS_VPN) | |
42e6d745 | 1740 | safi = SAFI_MPLS_LABELED_VPN; |
5228ad27 | 1741 | |
1742 | ndata[0] = (afi >> 8); | |
1743 | ndata[1] = afi; | |
1744 | ndata[2] = safi; | |
1745 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
1746 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
1747 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
1748 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 1749 | |
1750 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
1751 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
1752 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
1753 | } | |
0a486e5f | 1754 | |
1755 | /* restart timer start */ | |
1756 | if (peer->pmax_restart[afi][safi]) | |
1757 | { | |
1758 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
1759 | ||
1760 | if (BGP_DEBUG (events, EVENTS)) | |
1761 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", | |
1762 | peer->host, peer->v_pmax_restart); | |
1763 | ||
1764 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
1765 | peer->v_pmax_restart); | |
1766 | } | |
1767 | ||
e0701b79 | 1768 | return 1; |
1769 | } | |
1770 | else | |
1771 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
1772 | ||
1773 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
1774 | { | |
1775 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
1776 | && ! always) | |
1777 | return 0; | |
1778 | ||
1779 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1780 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
1781 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
1782 | peer->pmax[afi][safi]); | |
e0701b79 | 1783 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 1784 | } |
e0701b79 | 1785 | else |
1786 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 1787 | return 0; |
1788 | } | |
1789 | ||
b40d939b | 1790 | /* Unconditionally remove the route from the RIB, without taking |
1791 | * damping into consideration (eg, because the session went down) | |
1792 | */ | |
94f2b392 | 1793 | static void |
718e3744 | 1794 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
1795 | afi_t afi, safi_t safi) | |
1796 | { | |
902212c3 | 1797 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1798 | ||
1799 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
1800 | bgp_info_delete (rn, ri); /* keep historical info */ | |
1801 | ||
b40d939b | 1802 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 1803 | } |
1804 | ||
94f2b392 | 1805 | static void |
718e3744 | 1806 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 1807 | afi_t afi, safi_t safi) |
718e3744 | 1808 | { |
718e3744 | 1809 | int status = BGP_DAMP_NONE; |
1810 | ||
b40d939b | 1811 | /* apply dampening, if result is suppressed, we'll be retaining |
1812 | * the bgp_info in the RIB for historical reference. | |
1813 | */ | |
1814 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 1815 | && peer->sort == BGP_PEER_EBGP) |
b40d939b | 1816 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
1817 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 1818 | { |
902212c3 | 1819 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1820 | return; | |
1821 | } | |
1822 | ||
1823 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 1824 | } |
1825 | ||
94f2b392 | 1826 | static void |
fee0f4c6 | 1827 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1828 | struct attr *attr, struct peer *peer, struct prefix *p, int type, | |
1829 | int sub_type, struct prefix_rd *prd, u_char *tag) | |
1830 | { | |
1831 | struct bgp_node *rn; | |
1832 | struct bgp *bgp; | |
fb982c25 | 1833 | struct attr new_attr = { 0 }; |
fee0f4c6 | 1834 | struct attr *attr_new; |
1835 | struct attr *attr_new2; | |
1836 | struct bgp_info *ri; | |
1837 | struct bgp_info *new; | |
fd79ac91 | 1838 | const char *reason; |
fee0f4c6 | 1839 | char buf[SU_ADDRSTRLEN]; |
1840 | ||
1841 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ | |
1842 | if (peer == rsclient) | |
1843 | return; | |
1844 | ||
1845 | bgp = peer->bgp; | |
1846 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
1847 | ||
1848 | /* Check previously received route. */ | |
1849 | for (ri = rn->info; ri; ri = ri->next) | |
1850 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
1851 | break; | |
1852 | ||
1853 | /* AS path loop check. */ | |
1854 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) | |
1855 | { | |
1856 | reason = "as-path contains our own AS;"; | |
1857 | goto filtered; | |
1858 | } | |
1859 | ||
1860 | /* Route reflector originator ID check. */ | |
1861 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 1862 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
fee0f4c6 | 1863 | { |
1864 | reason = "originator is us;"; | |
1865 | goto filtered; | |
1866 | } | |
fb982c25 PJ |
1867 | |
1868 | bgp_attr_dup (&new_attr, attr); | |
fee0f4c6 | 1869 | |
1870 | /* Apply export policy. */ | |
1871 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && | |
1872 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1873 | { | |
1874 | reason = "export-policy;"; | |
1875 | goto filtered; | |
1876 | } | |
1877 | ||
1878 | attr_new2 = bgp_attr_intern (&new_attr); | |
fb982c25 | 1879 | |
fee0f4c6 | 1880 | /* Apply import policy. */ |
1881 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1882 | { | |
f6f434b2 | 1883 | bgp_attr_unintern (&attr_new2); |
fee0f4c6 | 1884 | |
1885 | reason = "import-policy;"; | |
1886 | goto filtered; | |
1887 | } | |
1888 | ||
1889 | attr_new = bgp_attr_intern (&new_attr); | |
f6f434b2 | 1890 | bgp_attr_unintern (&attr_new2); |
fee0f4c6 | 1891 | |
1892 | /* IPv4 unicast next hop check. */ | |
5a616c08 | 1893 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
fee0f4c6 | 1894 | { |
733cd9e5 | 1895 | /* Next hop must not be 0.0.0.0 nor Class D/E address. */ |
fee0f4c6 | 1896 | if (new_attr.nexthop.s_addr == 0 |
733cd9e5 | 1897 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
fee0f4c6 | 1898 | { |
f6f434b2 | 1899 | bgp_attr_unintern (&attr_new); |
fee0f4c6 | 1900 | |
1901 | reason = "martian next-hop;"; | |
1902 | goto filtered; | |
1903 | } | |
1904 | } | |
fb982c25 PJ |
1905 | |
1906 | /* new_attr isn't passed to any functions after here */ | |
1907 | bgp_attr_extra_free (&new_attr); | |
1908 | ||
fee0f4c6 | 1909 | /* If the update is implicit withdraw. */ |
1910 | if (ri) | |
1911 | { | |
65957886 | 1912 | ri->uptime = bgp_clock (); |
fee0f4c6 | 1913 | |
1914 | /* Same attribute comes in. */ | |
16d2e241 PJ |
1915 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
1916 | && attrhash_cmp (ri->attr, attr_new)) | |
fee0f4c6 | 1917 | { |
1918 | ||
1a392d46 | 1919 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1920 | |
1921 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1922 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1923 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
1924 | peer->host, | |
1925 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1926 | p->prefixlen, rsclient->host); | |
1927 | ||
228da428 | 1928 | bgp_unlock_node (rn); |
f6f434b2 | 1929 | bgp_attr_unintern (&attr_new); |
fee0f4c6 | 1930 | |
228da428 | 1931 | return; |
fee0f4c6 | 1932 | } |
1933 | ||
16d2e241 PJ |
1934 | /* Withdraw/Announce before we fully processed the withdraw */ |
1935 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
1936 | bgp_info_restore (rn, ri); | |
1937 | ||
fee0f4c6 | 1938 | /* Received Logging. */ |
1939 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1940 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1941 | peer->host, |
1942 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1943 | p->prefixlen, rsclient->host); | |
1944 | ||
1945 | /* The attribute is changed. */ | |
1a392d46 | 1946 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1947 | |
1948 | /* Update to new attribute. */ | |
f6f434b2 | 1949 | bgp_attr_unintern (&ri->attr); |
fee0f4c6 | 1950 | ri->attr = attr_new; |
1951 | ||
1952 | /* Update MPLS tag. */ | |
1953 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1954 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
fee0f4c6 | 1955 | |
1a392d46 | 1956 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
fee0f4c6 | 1957 | |
1958 | /* Process change. */ | |
1959 | bgp_process (bgp, rn, afi, safi); | |
1960 | bgp_unlock_node (rn); | |
1961 | ||
1962 | return; | |
1963 | } | |
1964 | ||
1965 | /* Received Logging. */ | |
1966 | if (BGP_DEBUG (update, UPDATE_IN)) | |
1967 | { | |
d2c1f16b | 1968 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1969 | peer->host, |
1970 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1971 | p->prefixlen, rsclient->host); | |
1972 | } | |
1973 | ||
1974 | /* Make new BGP info. */ | |
1975 | new = bgp_info_new (); | |
1976 | new->type = type; | |
1977 | new->sub_type = sub_type; | |
1978 | new->peer = peer; | |
1979 | new->attr = attr_new; | |
65957886 | 1980 | new->uptime = bgp_clock (); |
fee0f4c6 | 1981 | |
1982 | /* Update MPLS tag. */ | |
1983 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1984 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
fee0f4c6 | 1985 | |
1a392d46 | 1986 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
fee0f4c6 | 1987 | |
1988 | /* Register new BGP information. */ | |
1989 | bgp_info_add (rn, new); | |
200df115 | 1990 | |
1991 | /* route_node_get lock */ | |
1992 | bgp_unlock_node (rn); | |
1993 | ||
fee0f4c6 | 1994 | /* Process change. */ |
1995 | bgp_process (bgp, rn, afi, safi); | |
fb982c25 PJ |
1996 | |
1997 | bgp_attr_extra_free (&new_attr); | |
1998 | ||
fee0f4c6 | 1999 | return; |
2000 | ||
2001 | filtered: | |
2002 | ||
2003 | /* This BGP update is filtered. Log the reason then update BGP entry. */ | |
2004 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2005 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 2006 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
2007 | peer->host, | |
2008 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2009 | p->prefixlen, rsclient->host, reason); | |
2010 | ||
2011 | if (ri) | |
b40d939b | 2012 | bgp_rib_remove (rn, ri, peer, afi, safi); |
fee0f4c6 | 2013 | |
2014 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2015 | |
2016 | if (new_attr.extra) | |
2017 | bgp_attr_extra_free (&new_attr); | |
2018 | ||
fee0f4c6 | 2019 | return; |
2020 | } | |
2021 | ||
94f2b392 | 2022 | static void |
fee0f4c6 | 2023 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
2024 | struct peer *peer, struct prefix *p, int type, int sub_type, | |
2025 | struct prefix_rd *prd, u_char *tag) | |
228da428 | 2026 | { |
fee0f4c6 | 2027 | struct bgp_node *rn; |
2028 | struct bgp_info *ri; | |
2029 | char buf[SU_ADDRSTRLEN]; | |
2030 | ||
2031 | if (rsclient == peer) | |
228da428 | 2032 | return; |
fee0f4c6 | 2033 | |
2034 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
2035 | ||
2036 | /* Lookup withdrawn route. */ | |
2037 | for (ri = rn->info; ri; ri = ri->next) | |
2038 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2039 | break; | |
2040 | ||
2041 | /* Withdraw specified route from routing table. */ | |
2042 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2043 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
fee0f4c6 | 2044 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2045 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 2046 | "%s Can't find the route %s/%d", peer->host, |
2047 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2048 | p->prefixlen); | |
2049 | ||
2050 | /* Unlock bgp_node_get() lock. */ | |
228da428 CC |
2051 | bgp_unlock_node (rn); |
2052 | } | |
fee0f4c6 | 2053 | |
94f2b392 | 2054 | static int |
fee0f4c6 | 2055 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
718e3744 | 2056 | afi_t afi, safi_t safi, int type, int sub_type, |
2057 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2058 | { | |
2059 | int ret; | |
2060 | int aspath_loop_count = 0; | |
2061 | struct bgp_node *rn; | |
2062 | struct bgp *bgp; | |
fb982c25 | 2063 | struct attr new_attr = { 0 }; |
718e3744 | 2064 | struct attr *attr_new; |
2065 | struct bgp_info *ri; | |
2066 | struct bgp_info *new; | |
fd79ac91 | 2067 | const char *reason; |
718e3744 | 2068 | char buf[SU_ADDRSTRLEN]; |
2069 | ||
2070 | bgp = peer->bgp; | |
fee0f4c6 | 2071 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2072 | |
718e3744 | 2073 | /* When peer's soft reconfiguration enabled. Record input packet in |
2074 | Adj-RIBs-In. */ | |
2075 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2076 | && peer != bgp->peer_self && ! soft_reconfig) | |
2077 | bgp_adj_in_set (rn, peer, attr); | |
2078 | ||
2079 | /* Check previously received route. */ | |
2080 | for (ri = rn->info; ri; ri = ri->next) | |
2081 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2082 | break; | |
2083 | ||
2084 | /* AS path local-as loop check. */ | |
2085 | if (peer->change_local_as) | |
2086 | { | |
2087 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2088 | aspath_loop_count = 1; | |
2089 | ||
2090 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2091 | { | |
2092 | reason = "as-path contains our own AS;"; | |
2093 | goto filtered; | |
2094 | } | |
2095 | } | |
2096 | ||
2097 | /* AS path loop check. */ | |
2098 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2099 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2100 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2101 | > peer->allowas_in[afi][safi])) | |
2102 | { | |
2103 | reason = "as-path contains our own AS;"; | |
2104 | goto filtered; | |
2105 | } | |
2106 | ||
2107 | /* Route reflector originator ID check. */ | |
2108 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2109 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2110 | { |
2111 | reason = "originator is us;"; | |
2112 | goto filtered; | |
2113 | } | |
2114 | ||
2115 | /* Route reflector cluster ID check. */ | |
2116 | if (bgp_cluster_filter (peer, attr)) | |
2117 | { | |
2118 | reason = "reflected from the same cluster;"; | |
2119 | goto filtered; | |
2120 | } | |
2121 | ||
2122 | /* Apply incoming filter. */ | |
2123 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2124 | { | |
2125 | reason = "filter;"; | |
2126 | goto filtered; | |
2127 | } | |
2128 | ||
2129 | /* Apply incoming route-map. */ | |
fb982c25 | 2130 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2131 | |
2132 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
2133 | { | |
2134 | reason = "route-map;"; | |
2135 | goto filtered; | |
2136 | } | |
2137 | ||
2138 | /* IPv4 unicast next hop check. */ | |
2139 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
2140 | { | |
2141 | /* If the peer is EBGP and nexthop is not on connected route, | |
2142 | discard it. */ | |
6d85b15b | 2143 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
8e80bdf2 | 2144 | && ! bgp_nexthop_onlink (afi, &new_attr) |
6ffd2079 | 2145 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
718e3744 | 2146 | { |
2147 | reason = "non-connected next-hop;"; | |
2148 | goto filtered; | |
2149 | } | |
2150 | ||
733cd9e5 | 2151 | /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop |
718e3744 | 2152 | must not be my own address. */ |
10f9bf3f JBD |
2153 | if (new_attr.nexthop.s_addr == 0 |
2154 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) | |
2155 | || bgp_nexthop_self (&new_attr)) | |
718e3744 | 2156 | { |
2157 | reason = "martian next-hop;"; | |
2158 | goto filtered; | |
2159 | } | |
2160 | } | |
2161 | ||
2162 | attr_new = bgp_attr_intern (&new_attr); | |
2163 | ||
2164 | /* If the update is implicit withdraw. */ | |
2165 | if (ri) | |
2166 | { | |
65957886 | 2167 | ri->uptime = bgp_clock (); |
718e3744 | 2168 | |
2169 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2170 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2171 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2172 | { |
1a392d46 | 2173 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 2174 | |
2175 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2176 | && peer->sort == BGP_PEER_EBGP |
718e3744 | 2177 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2178 | { | |
2179 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2180 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2181 | peer->host, |
2182 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2183 | p->prefixlen); | |
2184 | ||
902212c3 | 2185 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2186 | { | |
2187 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2188 | bgp_process (bgp, rn, afi, safi); | |
2189 | } | |
718e3744 | 2190 | } |
16d2e241 | 2191 | else /* Duplicate - odd */ |
718e3744 | 2192 | { |
2193 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2194 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2195 | "%s rcvd %s/%d...duplicate ignored", |
2196 | peer->host, | |
2197 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2198 | p->prefixlen); | |
93406d87 | 2199 | |
2200 | /* graceful restart STALE flag unset. */ | |
2201 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2202 | { | |
1a392d46 | 2203 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2204 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2205 | } |
718e3744 | 2206 | } |
2207 | ||
2208 | bgp_unlock_node (rn); | |
f6f434b2 | 2209 | bgp_attr_unintern (&attr_new); |
fb982c25 PJ |
2210 | bgp_attr_extra_free (&new_attr); |
2211 | ||
718e3744 | 2212 | return 0; |
2213 | } | |
2214 | ||
16d2e241 PJ |
2215 | /* Withdraw/Announce before we fully processed the withdraw */ |
2216 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2217 | { | |
2218 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2219 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", | |
2220 | peer->host, | |
2221 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2222 | p->prefixlen); | |
2223 | bgp_info_restore (rn, ri); | |
2224 | } | |
2225 | ||
718e3744 | 2226 | /* Received Logging. */ |
2227 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2228 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2229 | peer->host, |
2230 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2231 | p->prefixlen); | |
2232 | ||
93406d87 | 2233 | /* graceful restart STALE flag unset. */ |
2234 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2235 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2236 | |
718e3744 | 2237 | /* The attribute is changed. */ |
1a392d46 | 2238 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2239 | |
2240 | /* implicit withdraw, decrement aggregate and pcount here. | |
2241 | * only if update is accepted, they'll increment below. | |
2242 | */ | |
902212c3 | 2243 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2244 | ||
718e3744 | 2245 | /* Update bgp route dampening information. */ |
2246 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2247 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2248 | { |
2249 | /* This is implicit withdraw so we should update dampening | |
2250 | information. */ | |
2251 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2252 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2253 | } |
2254 | ||
718e3744 | 2255 | /* Update to new attribute. */ |
f6f434b2 | 2256 | bgp_attr_unintern (&ri->attr); |
718e3744 | 2257 | ri->attr = attr_new; |
2258 | ||
2259 | /* Update MPLS tag. */ | |
2260 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2261 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2262 | |
2263 | /* Update bgp route dampening information. */ | |
2264 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2265 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2266 | { |
2267 | /* Now we do normal update dampening. */ | |
2268 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2269 | if (ret == BGP_DAMP_SUPPRESSED) | |
2270 | { | |
2271 | bgp_unlock_node (rn); | |
fb982c25 | 2272 | bgp_attr_extra_free (&new_attr); |
718e3744 | 2273 | return 0; |
2274 | } | |
2275 | } | |
2276 | ||
2277 | /* Nexthop reachability check. */ | |
2278 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2279 | && safi == SAFI_UNICAST | |
6d85b15b JBD |
2280 | && (peer->sort == BGP_PEER_IBGP |
2281 | || peer->sort == BGP_PEER_CONFED | |
2282 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) | |
6ffd2079 | 2283 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2284 | { |
2285 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) | |
1a392d46 | 2286 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2287 | else |
1a392d46 | 2288 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2289 | } |
2290 | else | |
1a392d46 | 2291 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2292 | |
2293 | /* Process change. */ | |
2294 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2295 | ||
2296 | bgp_process (bgp, rn, afi, safi); | |
2297 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2298 | bgp_attr_extra_free (&new_attr); |
2299 | ||
718e3744 | 2300 | return 0; |
2301 | } | |
2302 | ||
2303 | /* Received Logging. */ | |
2304 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2305 | { | |
d2c1f16b | 2306 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2307 | peer->host, |
2308 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2309 | p->prefixlen); | |
2310 | } | |
2311 | ||
718e3744 | 2312 | /* Make new BGP info. */ |
2313 | new = bgp_info_new (); | |
2314 | new->type = type; | |
2315 | new->sub_type = sub_type; | |
2316 | new->peer = peer; | |
2317 | new->attr = attr_new; | |
65957886 | 2318 | new->uptime = bgp_clock (); |
718e3744 | 2319 | |
2320 | /* Update MPLS tag. */ | |
2321 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2322 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2323 | |
2324 | /* Nexthop reachability check. */ | |
2325 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2326 | && safi == SAFI_UNICAST | |
6d85b15b JBD |
2327 | && (peer->sort == BGP_PEER_IBGP |
2328 | || peer->sort == BGP_PEER_CONFED | |
2329 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) | |
6ffd2079 | 2330 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2331 | { |
2332 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) | |
1a392d46 | 2333 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2334 | else |
1a392d46 | 2335 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2336 | } |
2337 | else | |
1a392d46 | 2338 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2339 | |
902212c3 | 2340 | /* Increment prefix */ |
718e3744 | 2341 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2342 | ||
2343 | /* Register new BGP information. */ | |
2344 | bgp_info_add (rn, new); | |
200df115 | 2345 | |
2346 | /* route_node_get lock */ | |
2347 | bgp_unlock_node (rn); | |
2348 | ||
fb982c25 PJ |
2349 | bgp_attr_extra_free (&new_attr); |
2350 | ||
718e3744 | 2351 | /* If maximum prefix count is configured and current prefix |
2352 | count exeed it. */ | |
e0701b79 | 2353 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2354 | return -1; | |
718e3744 | 2355 | |
2356 | /* Process change. */ | |
2357 | bgp_process (bgp, rn, afi, safi); | |
2358 | ||
2359 | return 0; | |
2360 | ||
2361 | /* This BGP update is filtered. Log the reason then update BGP | |
2362 | entry. */ | |
2363 | filtered: | |
2364 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2365 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2366 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
2367 | peer->host, | |
2368 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2369 | p->prefixlen, reason); | |
2370 | ||
2371 | if (ri) | |
b40d939b | 2372 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2373 | |
2374 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2375 | |
2376 | bgp_attr_extra_free (&new_attr); | |
2377 | ||
718e3744 | 2378 | return 0; |
2379 | } | |
2380 | ||
fee0f4c6 | 2381 | int |
2382 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, | |
2383 | afi_t afi, safi_t safi, int type, int sub_type, | |
2384 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2385 | { | |
2386 | struct peer *rsclient; | |
1eb8ef25 | 2387 | struct listnode *node, *nnode; |
fee0f4c6 | 2388 | struct bgp *bgp; |
2389 | int ret; | |
2390 | ||
2391 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, | |
2392 | soft_reconfig); | |
2393 | ||
2394 | bgp = peer->bgp; | |
2395 | ||
2396 | /* Process the update for each RS-client. */ | |
1eb8ef25 | 2397 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2398 | { |
2399 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2400 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, | |
2401 | sub_type, prd, tag); | |
2402 | } | |
2403 | ||
2404 | return ret; | |
2405 | } | |
2406 | ||
718e3744 | 2407 | int |
2408 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, | |
94f2b392 | 2409 | afi_t afi, safi_t safi, int type, int sub_type, |
2410 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2411 | { |
2412 | struct bgp *bgp; | |
2413 | char buf[SU_ADDRSTRLEN]; | |
2414 | struct bgp_node *rn; | |
2415 | struct bgp_info *ri; | |
fee0f4c6 | 2416 | struct peer *rsclient; |
1eb8ef25 | 2417 | struct listnode *node, *nnode; |
718e3744 | 2418 | |
2419 | bgp = peer->bgp; | |
2420 | ||
fee0f4c6 | 2421 | /* Process the withdraw for each RS-client. */ |
1eb8ef25 | 2422 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2423 | { |
2424 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2425 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); | |
2426 | } | |
2427 | ||
718e3744 | 2428 | /* Logging. */ |
2429 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2430 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
718e3744 | 2431 | peer->host, |
2432 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2433 | p->prefixlen); | |
2434 | ||
2435 | /* Lookup node. */ | |
fee0f4c6 | 2436 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2437 | |
2438 | /* If peer is soft reconfiguration enabled. Record input packet for | |
2439 | further calculation. */ | |
2440 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2441 | && peer != bgp->peer_self) | |
2442 | bgp_adj_in_unset (rn, peer); | |
2443 | ||
2444 | /* Lookup withdrawn route. */ | |
2445 | for (ri = rn->info; ri; ri = ri->next) | |
2446 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2447 | break; | |
2448 | ||
2449 | /* Withdraw specified route from routing table. */ | |
2450 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2451 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
718e3744 | 2452 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2453 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2454 | "%s Can't find the route %s/%d", peer->host, |
2455 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2456 | p->prefixlen); | |
2457 | ||
2458 | /* Unlock bgp_node_get() lock. */ | |
2459 | bgp_unlock_node (rn); | |
2460 | ||
2461 | return 0; | |
2462 | } | |
2463 | \f | |
2464 | void | |
2465 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2466 | { | |
2467 | struct bgp *bgp; | |
228da428 | 2468 | struct attr attr = { 0 }; |
fb982c25 | 2469 | struct aspath *aspath = { 0 }; |
718e3744 | 2470 | struct prefix p; |
2471 | struct bgp_info binfo; | |
2472 | struct peer *from; | |
2473 | int ret = RMAP_DENYMATCH; | |
fb982c25 | 2474 | |
b2497024 | 2475 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
fb982c25 PJ |
2476 | return; |
2477 | ||
718e3744 | 2478 | bgp = peer->bgp; |
2479 | from = bgp->peer_self; | |
fb982c25 | 2480 | |
718e3744 | 2481 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
2482 | aspath = attr.aspath; | |
2483 | attr.local_pref = bgp->default_local_pref; | |
2484 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
2485 | ||
2486 | if (afi == AFI_IP) | |
2487 | str2prefix ("0.0.0.0/0", &p); | |
2488 | #ifdef HAVE_IPV6 | |
2489 | else if (afi == AFI_IP6) | |
2490 | { | |
fb982c25 PJ |
2491 | struct attr_extra *ae; |
2492 | attr.extra = NULL; | |
2493 | ||
2494 | ae = bgp_attr_extra_get (&attr); | |
2495 | attr.extra = ae; | |
2496 | ||
718e3744 | 2497 | str2prefix ("::/0", &p); |
2498 | ||
2499 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 2500 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 2501 | IPV6_MAX_BYTELEN); |
fb982c25 | 2502 | ae->mp_nexthop_len = 16; |
718e3744 | 2503 | |
2504 | /* If the peer is on shared nextwork and we have link-local | |
2505 | nexthop set it. */ | |
2506 | if (peer->shared_network | |
2507 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
2508 | { | |
fb982c25 | 2509 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 2510 | IPV6_MAX_BYTELEN); |
fb982c25 | 2511 | ae->mp_nexthop_len = 32; |
718e3744 | 2512 | } |
2513 | } | |
2514 | #endif /* HAVE_IPV6 */ | |
718e3744 | 2515 | |
2516 | if (peer->default_rmap[afi][safi].name) | |
2517 | { | |
2518 | binfo.peer = bgp->peer_self; | |
2519 | binfo.attr = &attr; | |
2520 | ||
fee0f4c6 | 2521 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
2522 | ||
718e3744 | 2523 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
2524 | RMAP_BGP, &binfo); | |
2525 | ||
fee0f4c6 | 2526 | bgp->peer_self->rmap_type = 0; |
2527 | ||
718e3744 | 2528 | if (ret == RMAP_DENYMATCH) |
2529 | { | |
2530 | bgp_attr_flush (&attr); | |
2531 | withdraw = 1; | |
2532 | } | |
2533 | } | |
2534 | ||
2535 | if (withdraw) | |
2536 | { | |
2537 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
2538 | bgp_default_withdraw_send (peer, afi, safi); | |
2539 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2540 | } | |
2541 | else | |
2542 | { | |
2543 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2544 | bgp_default_update_send (peer, &attr, afi, safi, from); | |
2545 | } | |
fb982c25 PJ |
2546 | |
2547 | bgp_attr_extra_free (&attr); | |
f6f434b2 | 2548 | aspath_unintern (&aspath); |
718e3744 | 2549 | } |
2550 | \f | |
2551 | static void | |
2552 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, | |
fee0f4c6 | 2553 | struct bgp_table *table, int rsclient) |
718e3744 | 2554 | { |
2555 | struct bgp_node *rn; | |
2556 | struct bgp_info *ri; | |
228da428 | 2557 | struct attr attr = { 0 }; |
fb982c25 | 2558 | |
718e3744 | 2559 | if (! table) |
fee0f4c6 | 2560 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
718e3744 | 2561 | |
2562 | if (safi != SAFI_MPLS_VPN | |
2563 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
2564 | bgp_default_originate (peer, afi, safi, 0); | |
2565 | ||
2566 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) | |
2567 | for (ri = rn->info; ri; ri = ri->next) | |
2568 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) | |
2569 | { | |
fee0f4c6 | 2570 | if ( (rsclient) ? |
2571 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) | |
2572 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) | |
718e3744 | 2573 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
2574 | else | |
2575 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); | |
fb982c25 PJ |
2576 | |
2577 | bgp_attr_extra_free (&attr); | |
718e3744 | 2578 | } |
2579 | } | |
2580 | ||
2581 | void | |
2582 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2583 | { | |
2584 | struct bgp_node *rn; | |
2585 | struct bgp_table *table; | |
2586 | ||
2587 | if (peer->status != Established) | |
2588 | return; | |
2589 | ||
2590 | if (! peer->afc_nego[afi][safi]) | |
2591 | return; | |
2592 | ||
2593 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ | |
2594 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
2595 | return; | |
2596 | ||
2597 | if (safi != SAFI_MPLS_VPN) | |
fee0f4c6 | 2598 | bgp_announce_table (peer, afi, safi, NULL, 0); |
718e3744 | 2599 | else |
2600 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2601 | rn = bgp_route_next(rn)) | |
2602 | if ((table = (rn->info)) != NULL) | |
fee0f4c6 | 2603 | bgp_announce_table (peer, afi, safi, table, 0); |
2604 | ||
2605 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2606 | bgp_announce_table (peer, afi, safi, NULL, 1); | |
718e3744 | 2607 | } |
2608 | ||
2609 | void | |
2610 | bgp_announce_route_all (struct peer *peer) | |
2611 | { | |
2612 | afi_t afi; | |
2613 | safi_t safi; | |
2614 | ||
2615 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2616 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2617 | bgp_announce_route (peer, afi, safi); | |
2618 | } | |
2619 | \f | |
2620 | static void | |
fee0f4c6 | 2621 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
8692c506 | 2622 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
fee0f4c6 | 2623 | { |
2624 | struct bgp_node *rn; | |
2625 | struct bgp_adj_in *ain; | |
2626 | ||
2627 | if (! table) | |
2628 | table = rsclient->bgp->rib[afi][safi]; | |
2629 | ||
2630 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2631 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2632 | { | |
8692c506 JBD |
2633 | struct bgp_info *ri = rn->info; |
2634 | ||
fee0f4c6 | 2635 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
8692c506 JBD |
2636 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, |
2637 | (bgp_info_extra_get (ri))->tag); | |
fee0f4c6 | 2638 | } |
2639 | } | |
2640 | ||
2641 | void | |
2642 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
2643 | { | |
2644 | struct bgp_table *table; | |
2645 | struct bgp_node *rn; | |
2646 | ||
2647 | if (safi != SAFI_MPLS_VPN) | |
8692c506 | 2648 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
fee0f4c6 | 2649 | |
2650 | else | |
2651 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; | |
2652 | rn = bgp_route_next (rn)) | |
2653 | if ((table = rn->info) != NULL) | |
8692c506 JBD |
2654 | { |
2655 | struct prefix_rd prd; | |
2656 | prd.family = AF_UNSPEC; | |
2657 | prd.prefixlen = 64; | |
2658 | memcpy(&prd.val, rn->p.u.val, 8); | |
2659 | ||
2660 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); | |
2661 | } | |
fee0f4c6 | 2662 | } |
2663 | \f | |
2664 | static void | |
718e3744 | 2665 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
8692c506 | 2666 | struct bgp_table *table, struct prefix_rd *prd) |
718e3744 | 2667 | { |
2668 | int ret; | |
2669 | struct bgp_node *rn; | |
2670 | struct bgp_adj_in *ain; | |
2671 | ||
2672 | if (! table) | |
2673 | table = peer->bgp->rib[afi][safi]; | |
2674 | ||
2675 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2676 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2677 | { | |
2678 | if (ain->peer == peer) | |
2679 | { | |
8692c506 JBD |
2680 | struct bgp_info *ri = rn->info; |
2681 | ||
718e3744 | 2682 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
2683 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, | |
8692c506 JBD |
2684 | prd, (bgp_info_extra_get (ri))->tag, 1); |
2685 | ||
718e3744 | 2686 | if (ret < 0) |
2687 | { | |
2688 | bgp_unlock_node (rn); | |
2689 | return; | |
2690 | } | |
2691 | continue; | |
2692 | } | |
2693 | } | |
2694 | } | |
2695 | ||
2696 | void | |
2697 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2698 | { | |
2699 | struct bgp_node *rn; | |
2700 | struct bgp_table *table; | |
2701 | ||
2702 | if (peer->status != Established) | |
2703 | return; | |
2704 | ||
2705 | if (safi != SAFI_MPLS_VPN) | |
8692c506 | 2706 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
718e3744 | 2707 | else |
2708 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2709 | rn = bgp_route_next (rn)) | |
2710 | if ((table = rn->info) != NULL) | |
8692c506 JBD |
2711 | { |
2712 | struct prefix_rd prd; | |
2713 | prd.family = AF_UNSPEC; | |
2714 | prd.prefixlen = 64; | |
2715 | memcpy(&prd.val, rn->p.u.val, 8); | |
2716 | ||
2717 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); | |
2718 | } | |
718e3744 | 2719 | } |
2720 | \f | |
228da428 CC |
2721 | |
2722 | struct bgp_clear_node_queue | |
2723 | { | |
2724 | struct bgp_node *rn; | |
2725 | enum bgp_clear_route_type purpose; | |
2726 | }; | |
2727 | ||
200df115 | 2728 | static wq_item_status |
0fb58d5d | 2729 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2730 | { |
228da428 CC |
2731 | struct bgp_clear_node_queue *cnq = data; |
2732 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2733 | struct peer *peer = wq->spec.data; |
718e3744 | 2734 | struct bgp_info *ri; |
64e580a7 PJ |
2735 | afi_t afi = rn->table->afi; |
2736 | safi_t safi = rn->table->safi; | |
200df115 | 2737 | |
64e580a7 | 2738 | assert (rn && peer); |
200df115 | 2739 | |
64e580a7 | 2740 | for (ri = rn->info; ri; ri = ri->next) |
228da428 | 2741 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
200df115 | 2742 | { |
2743 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2744 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2745 | && peer->nsf[afi][safi] | |
200df115 | 2746 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2747 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2748 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2749 | else |
64e580a7 | 2750 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2751 | break; |
2752 | } | |
200df115 | 2753 | return WQ_SUCCESS; |
2754 | } | |
2755 | ||
2756 | static void | |
0fb58d5d | 2757 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2758 | { |
228da428 CC |
2759 | struct bgp_clear_node_queue *cnq = data; |
2760 | struct bgp_node *rn = cnq->rn; | |
2761 | struct bgp_table *table = rn->table; | |
64e580a7 PJ |
2762 | |
2763 | bgp_unlock_node (rn); | |
228da428 CC |
2764 | bgp_table_unlock (table); |
2765 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2766 | } |
2767 | ||
2768 | static void | |
94f2b392 | 2769 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2770 | { |
64e580a7 PJ |
2771 | struct peer *peer = wq->spec.data; |
2772 | ||
3e0c78ef | 2773 | /* Tickle FSM to start moving again */ |
ca058a30 | 2774 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2775 | |
2776 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2777 | } |
2778 | ||
2779 | static void | |
64e580a7 | 2780 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2781 | { |
a2943657 | 2782 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2783 | |
a2943657 | 2784 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2785 | #undef CLEAR_QUEUE_NAME_LEN |
2786 | ||
2787 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) | |
200df115 | 2788 | { |
2789 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2790 | exit (1); | |
2791 | } | |
64e580a7 PJ |
2792 | peer->clear_node_queue->spec.hold = 10; |
2793 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2794 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2795 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2796 | peer->clear_node_queue->spec.max_retries = 0; | |
2797 | ||
2798 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2799 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2800 | } |
718e3744 | 2801 | |
200df115 | 2802 | static void |
2803 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
228da428 CC |
2804 | struct bgp_table *table, struct peer *rsclient, |
2805 | enum bgp_clear_route_type purpose) | |
200df115 | 2806 | { |
200df115 | 2807 | struct bgp_node *rn; |
2808 | ||
f2c31acb | 2809 | |
718e3744 | 2810 | if (! table) |
fee0f4c6 | 2811 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
64e580a7 | 2812 | |
6cf159b9 | 2813 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2814 | if (! table) | |
2815 | return; | |
65ca75e0 PJ |
2816 | |
2817 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2818 | { | |
f2c31acb PJ |
2819 | struct bgp_info *ri; |
2820 | struct bgp_adj_in *ain; | |
2821 | struct bgp_adj_out *aout; | |
2822 | ||
65ca75e0 PJ |
2823 | if (rn->info == NULL) |
2824 | continue; | |
f2c31acb PJ |
2825 | |
2826 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2827 | * queued for every clearing peer, regardless of whether it is | |
2828 | * relevant to the peer at hand. | |
2829 | * | |
2830 | * Overview: There are 3 different indices which need to be | |
2831 | * scrubbed, potentially, when a peer is removed: | |
2832 | * | |
2833 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2834 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2835 | * 3 other routes visible by the peer's adj-out index | |
2836 | * | |
2837 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2838 | * removed from bgp->peer, we could just GC such deleted peer's | |
2839 | * adj-outs at our leisure. | |
2840 | * | |
2841 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2842 | * invisible via RIB index before peer session is allowed to be | |
2843 | * brought back up. So one needs to know when such a 'search' is | |
2844 | * complete. | |
2845 | * | |
2846 | * Ideally: | |
2847 | * | |
2848 | * - there'd be a single global queue or a single RIB walker | |
2849 | * - rather than tracking which route_nodes still need to be | |
2850 | * examined on a peer basis, we'd track which peers still | |
2851 | * aren't cleared | |
2852 | * | |
2853 | * Given that our per-peer prefix-counts now should be reliable, | |
2854 | * this may actually be achievable. It doesn't seem to be a huge | |
2855 | * problem at this time, | |
2856 | */ | |
2857 | for (ri = rn->info; ri; ri = ri->next) | |
228da428 | 2858 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb | 2859 | { |
228da428 CC |
2860 | struct bgp_clear_node_queue *cnq; |
2861 | ||
2862 | /* both unlocked in bgp_clear_node_queue_del */ | |
2863 | bgp_table_lock (rn->table); | |
2864 | bgp_lock_node (rn); | |
2865 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2866 | sizeof (struct bgp_clear_node_queue)); | |
2867 | cnq->rn = rn; | |
2868 | cnq->purpose = purpose; | |
2869 | work_queue_add (peer->clear_node_queue, cnq); | |
2870 | break; | |
f2c31acb PJ |
2871 | } |
2872 | ||
2873 | for (ain = rn->adj_in; ain; ain = ain->next) | |
228da428 | 2874 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2875 | { |
2876 | bgp_adj_in_remove (rn, ain); | |
2877 | bgp_unlock_node (rn); | |
2878 | break; | |
2879 | } | |
2880 | for (aout = rn->adj_out; aout; aout = aout->next) | |
228da428 | 2881 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2882 | { |
2883 | bgp_adj_out_remove (rn, aout, peer, afi, safi); | |
2884 | bgp_unlock_node (rn); | |
2885 | break; | |
2886 | } | |
65ca75e0 PJ |
2887 | } |
2888 | return; | |
2889 | } | |
2890 | ||
2891 | void | |
228da428 CC |
2892 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
2893 | enum bgp_clear_route_type purpose) | |
65ca75e0 PJ |
2894 | { |
2895 | struct bgp_node *rn; | |
2896 | struct bgp_table *table; | |
2897 | struct peer *rsclient; | |
2898 | struct listnode *node, *nnode; | |
6cf159b9 | 2899 | |
64e580a7 PJ |
2900 | if (peer->clear_node_queue == NULL) |
2901 | bgp_clear_node_queue_init (peer); | |
200df115 | 2902 | |
ca058a30 PJ |
2903 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2904 | * Idle until it receives a Clearing_Completed event. This protects | |
2905 | * against peers which flap faster than we can we clear, which could | |
2906 | * lead to: | |
64e580a7 PJ |
2907 | * |
2908 | * a) race with routes from the new session being installed before | |
2909 | * clear_route_node visits the node (to delete the route of that | |
2910 | * peer) | |
2911 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2912 | * on the process_main queue. Fast-flapping could cause that queue | |
2913 | * to grow and grow. | |
200df115 | 2914 | */ |
ca058a30 PJ |
2915 | if (!peer->clear_node_queue->thread) |
2916 | peer_lock (peer); /* bgp_clear_node_complete */ | |
fee0f4c6 | 2917 | |
228da428 | 2918 | switch (purpose) |
fee0f4c6 | 2919 | { |
228da428 CC |
2920 | case BGP_CLEAR_ROUTE_NORMAL: |
2921 | if (safi != SAFI_MPLS_VPN) | |
2922 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); | |
2923 | else | |
2924 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2925 | rn = bgp_route_next (rn)) | |
2926 | if ((table = rn->info) != NULL) | |
2927 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); | |
2928 | ||
2929 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) | |
2930 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], | |
2931 | PEER_FLAG_RSERVER_CLIENT)) | |
2932 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); | |
2933 | break; | |
2934 | ||
2935 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: | |
2936 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); | |
2937 | break; | |
2938 | ||
2939 | default: | |
2940 | assert (0); | |
2941 | break; | |
fee0f4c6 | 2942 | } |
65ca75e0 | 2943 | |
ca058a30 | 2944 | /* If no routes were cleared, nothing was added to workqueue, the |
f2c31acb PJ |
2945 | * completion function won't be run by workqueue code - call it here. |
2946 | * XXX: Actually, this assumption doesn't hold, see | |
2947 | * bgp_clear_route_table(), we queue all non-empty nodes. | |
ca058a30 PJ |
2948 | * |
2949 | * Additionally, there is a presumption in FSM that clearing is only | |
f2c31acb PJ |
2950 | * really needed if peer state is Established - peers in |
2951 | * pre-Established states shouldn't have any route-update state | |
2952 | * associated with them (in or out). | |
ca058a30 | 2953 | * |
f2c31acb PJ |
2954 | * We still can get here in pre-Established though, through |
2955 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity | |
2956 | * check to ensure the assumption above holds. | |
ca058a30 PJ |
2957 | * |
2958 | * At some future point, this check could be move to the top of the | |
2959 | * function, and do a quick early-return when state is | |
2960 | * pre-Established, avoiding above list and table scans. Once we're | |
2961 | * sure it is safe.. | |
65ca75e0 PJ |
2962 | */ |
2963 | if (!peer->clear_node_queue->thread) | |
2964 | bgp_clear_node_complete (peer->clear_node_queue); | |
718e3744 | 2965 | } |
2966 | ||
2967 | void | |
2968 | bgp_clear_route_all (struct peer *peer) | |
2969 | { | |
2970 | afi_t afi; | |
2971 | safi_t safi; | |
2972 | ||
2973 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2974 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
228da428 | 2975 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
718e3744 | 2976 | } |
2977 | ||
2978 | void | |
2979 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
2980 | { | |
2981 | struct bgp_table *table; | |
2982 | struct bgp_node *rn; | |
2983 | struct bgp_adj_in *ain; | |
2984 | ||
2985 | table = peer->bgp->rib[afi][safi]; | |
2986 | ||
2987 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2988 | for (ain = rn->adj_in; ain ; ain = ain->next) | |
2989 | if (ain->peer == peer) | |
2990 | { | |
2991 | bgp_adj_in_remove (rn, ain); | |
2992 | bgp_unlock_node (rn); | |
2993 | break; | |
2994 | } | |
2995 | } | |
93406d87 | 2996 | |
2997 | void | |
2998 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
2999 | { | |
3000 | struct bgp_node *rn; | |
3001 | struct bgp_info *ri; | |
3002 | struct bgp_table *table; | |
3003 | ||
3004 | table = peer->bgp->rib[afi][safi]; | |
3005 | ||
3006 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3007 | { | |
3008 | for (ri = rn->info; ri; ri = ri->next) | |
3009 | if (ri->peer == peer) | |
3010 | { | |
3011 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
3012 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
3013 | break; | |
3014 | } | |
3015 | } | |
3016 | } | |
718e3744 | 3017 | \f |
3018 | /* Delete all kernel routes. */ | |
3019 | void | |
66e5cd87 | 3020 | bgp_cleanup_routes (void) |
718e3744 | 3021 | { |
3022 | struct bgp *bgp; | |
1eb8ef25 | 3023 | struct listnode *node, *nnode; |
718e3744 | 3024 | struct bgp_node *rn; |
3025 | struct bgp_table *table; | |
3026 | struct bgp_info *ri; | |
3027 | ||
1eb8ef25 | 3028 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 3029 | { |
3030 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; | |
3031 | ||
3032 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3033 | for (ri = rn->info; ri; ri = ri->next) | |
3034 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
3035 | && ri->type == ZEBRA_ROUTE_BGP | |
3036 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
5a616c08 | 3037 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
718e3744 | 3038 | |
3039 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; | |
3040 | ||
3041 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3042 | for (ri = rn->info; ri; ri = ri->next) | |
3043 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
3044 | && ri->type == ZEBRA_ROUTE_BGP | |
3045 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
5a616c08 | 3046 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
718e3744 | 3047 | } |
3048 | } | |
3049 | ||
3050 | void | |
66e5cd87 | 3051 | bgp_reset (void) |
718e3744 | 3052 | { |
3053 | vty_reset (); | |
3054 | bgp_zclient_reset (); | |
3055 | access_list_reset (); | |
3056 | prefix_list_reset (); | |
3057 | } | |
3058 | \f | |
3059 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr | |
3060 | value. */ | |
3061 | int | |
3062 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
3063 | { | |
3064 | u_char *pnt; | |
3065 | u_char *lim; | |
3066 | struct prefix p; | |
3067 | int psize; | |
3068 | int ret; | |
3069 | ||
3070 | /* Check peer status. */ | |
3071 | if (peer->status != Established) | |
3072 | return 0; | |
3073 | ||
3074 | pnt = packet->nlri; | |
3075 | lim = pnt + packet->length; | |
3076 | ||
3077 | for (; pnt < lim; pnt += psize) | |
3078 | { | |
3079 | /* Clear prefix structure. */ | |
3080 | memset (&p, 0, sizeof (struct prefix)); | |
3081 | ||
3082 | /* Fetch prefix length. */ | |
3083 | p.prefixlen = *pnt++; | |
3084 | p.family = afi2family (packet->afi); | |
3085 | ||
3086 | /* Already checked in nlri_sanity_check(). We do double check | |
3087 | here. */ | |
3088 | if ((packet->afi == AFI_IP && p.prefixlen > 32) | |
3089 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) | |
3090 | return -1; | |
3091 | ||
3092 | /* Packet size overflow check. */ | |
3093 | psize = PSIZE (p.prefixlen); | |
3094 | ||
3095 | /* When packet overflow occur return immediately. */ | |
3096 | if (pnt + psize > lim) | |
3097 | return -1; | |
3098 | ||
3099 | /* Fetch prefix from NLRI packet. */ | |
3100 | memcpy (&p.u.prefix, pnt, psize); | |
3101 | ||
3102 | /* Check address. */ | |
3103 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) | |
3104 | { | |
3105 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3106 | { | |
f5ba3874 | 3107 | /* |
3108 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3109 | * If a BGP router receives an UPDATE message with a | |
3110 | * semantically incorrect NLRI field, in which a prefix is | |
3111 | * semantically incorrect (eg. an unexpected multicast IP | |
3112 | * address), it should ignore the prefix. | |
3113 | */ | |
718e3744 | 3114 | zlog (peer->log, LOG_ERR, |
3115 | "IPv4 unicast NLRI is multicast address %s", | |
3116 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3117 | |
718e3744 | 3118 | return -1; |
3119 | } | |
3120 | } | |
3121 | ||
3122 | #ifdef HAVE_IPV6 | |
3123 | /* Check address. */ | |
3124 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) | |
3125 | { | |
3126 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3127 | { | |
3128 | char buf[BUFSIZ]; | |
3129 | ||
3130 | zlog (peer->log, LOG_WARNING, | |
3131 | "IPv6 link-local NLRI received %s ignore this NLRI", | |
3132 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
3133 | ||
3134 | continue; | |
3135 | } | |
3136 | } | |
3137 | #endif /* HAVE_IPV6 */ | |
3138 | ||
3139 | /* Normal process. */ | |
3140 | if (attr) | |
3141 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, | |
3142 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); | |
3143 | else | |
3144 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, | |
3145 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
3146 | ||
3147 | /* Address family configuration mismatch or maximum-prefix count | |
3148 | overflow. */ | |
3149 | if (ret < 0) | |
3150 | return -1; | |
3151 | } | |
3152 | ||
3153 | /* Packet length consistency check. */ | |
3154 | if (pnt != lim) | |
3155 | return -1; | |
3156 | ||
3157 | return 0; | |
3158 | } | |
3159 | ||
3160 | /* NLRI encode syntax check routine. */ | |
3161 | int | |
3162 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, | |
3163 | bgp_size_t length) | |
3164 | { | |
3165 | u_char *end; | |
3166 | u_char prefixlen; | |
3167 | int psize; | |
3168 | ||
3169 | end = pnt + length; | |
3170 | ||
3171 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for | |
3172 | syntactic validity. If the field is syntactically incorrect, | |
3173 | then the Error Subcode is set to Invalid Network Field. */ | |
3174 | ||
3175 | while (pnt < end) | |
3176 | { | |
3177 | prefixlen = *pnt++; | |
3178 | ||
3179 | /* Prefix length check. */ | |
3180 | if ((afi == AFI_IP && prefixlen > 32) | |
3181 | || (afi == AFI_IP6 && prefixlen > 128)) | |
3182 | { | |
3183 | plog_err (peer->log, | |
3184 | "%s [Error] Update packet error (wrong prefix length %d)", | |
3185 | peer->host, prefixlen); | |
3186 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3187 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3188 | return -1; | |
3189 | } | |
3190 | ||
3191 | /* Packet size overflow check. */ | |
3192 | psize = PSIZE (prefixlen); | |
3193 | ||
3194 | if (pnt + psize > end) | |
3195 | { | |
3196 | plog_err (peer->log, | |
3197 | "%s [Error] Update packet error" | |
3198 | " (prefix data overflow prefix size is %d)", | |
3199 | peer->host, psize); | |
3200 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3201 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3202 | return -1; | |
3203 | } | |
3204 | ||
3205 | pnt += psize; | |
3206 | } | |
3207 | ||
3208 | /* Packet length consistency check. */ | |
3209 | if (pnt != end) | |
3210 | { | |
3211 | plog_err (peer->log, | |
3212 | "%s [Error] Update packet error" | |
3213 | " (prefix length mismatch with total length)", | |
3214 | peer->host); | |
3215 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3216 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3217 | return -1; | |
3218 | } | |
3219 | return 0; | |
3220 | } | |
3221 | \f | |
94f2b392 | 3222 | static struct bgp_static * |
66e5cd87 | 3223 | bgp_static_new (void) |
718e3744 | 3224 | { |
393deb9b | 3225 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3226 | } |
3227 | ||
94f2b392 | 3228 | static void |
718e3744 | 3229 | bgp_static_free (struct bgp_static *bgp_static) |
3230 | { | |
3231 | if (bgp_static->rmap.name) | |
3232 | free (bgp_static->rmap.name); | |
3233 | XFREE (MTYPE_BGP_STATIC, bgp_static); | |
3234 | } | |
3235 | ||
94f2b392 | 3236 | static void |
fee0f4c6 | 3237 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
3238 | struct prefix *p, afi_t afi, safi_t safi) | |
3239 | { | |
3240 | struct bgp_node *rn; | |
3241 | struct bgp_info *ri; | |
3242 | ||
3243 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); | |
3244 | ||
3245 | /* Check selected route and self inserted route. */ | |
3246 | for (ri = rn->info; ri; ri = ri->next) | |
3247 | if (ri->peer == bgp->peer_self | |
3248 | && ri->type == ZEBRA_ROUTE_BGP | |
3249 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3250 | break; | |
3251 | ||
3252 | /* Withdraw static BGP route from routing table. */ | |
3253 | if (ri) | |
3254 | { | |
fee0f4c6 | 3255 | bgp_info_delete (rn, ri); |
1a392d46 | 3256 | bgp_process (bgp, rn, afi, safi); |
fee0f4c6 | 3257 | } |
3258 | ||
3259 | /* Unlock bgp_node_lookup. */ | |
3260 | bgp_unlock_node (rn); | |
3261 | } | |
3262 | ||
94f2b392 | 3263 | static void |
fee0f4c6 | 3264 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
fb982c25 PJ |
3265 | struct bgp_static *bgp_static, |
3266 | afi_t afi, safi_t safi) | |
fee0f4c6 | 3267 | { |
3268 | struct bgp_node *rn; | |
3269 | struct bgp_info *ri; | |
3270 | struct bgp_info *new; | |
3271 | struct bgp_info info; | |
fee0f4c6 | 3272 | struct attr *attr_new; |
fb982c25 PJ |
3273 | struct attr attr = {0 }; |
3274 | struct attr new_attr = { .extra = 0 }; | |
fee0f4c6 | 3275 | struct bgp *bgp; |
3276 | int ret; | |
3277 | char buf[SU_ADDRSTRLEN]; | |
3278 | ||
3279 | bgp = rsclient->bgp; | |
3280 | ||
06e110f9 PJ |
3281 | assert (bgp_static); |
3282 | if (!bgp_static) | |
3283 | return; | |
3284 | ||
fee0f4c6 | 3285 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
3286 | ||
3287 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
06e110f9 PJ |
3288 | |
3289 | attr.nexthop = bgp_static->igpnexthop; | |
3290 | attr.med = bgp_static->igpmetric; | |
3291 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
41367172 | 3292 | |
41367172 PJ |
3293 | if (bgp_static->atomic) |
3294 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3295 | ||
fee0f4c6 | 3296 | /* Apply network route-map for export to this rsclient. */ |
3297 | if (bgp_static->rmap.name) | |
3298 | { | |
fb982c25 | 3299 | struct attr attr_tmp = attr; |
fee0f4c6 | 3300 | info.peer = rsclient; |
fb982c25 PJ |
3301 | info.attr = &attr_tmp; |
3302 | ||
fee0f4c6 | 3303 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
3304 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); | |
3305 | ||
3306 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); | |
3307 | ||
3308 | rsclient->rmap_type = 0; | |
3309 | ||
3310 | if (ret == RMAP_DENYMATCH) | |
3311 | { | |
3312 | /* Free uninterned attribute. */ | |
fb982c25 | 3313 | bgp_attr_flush (&attr_tmp); |
fee0f4c6 | 3314 | |
3315 | /* Unintern original. */ | |
f6f434b2 | 3316 | aspath_unintern (&attr.aspath); |
fee0f4c6 | 3317 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
fb982c25 PJ |
3318 | bgp_attr_extra_free (&attr); |
3319 | ||
fee0f4c6 | 3320 | return; |
3321 | } | |
fb982c25 | 3322 | attr_new = bgp_attr_intern (&attr_tmp); |
fee0f4c6 | 3323 | } |
3324 | else | |
3325 | attr_new = bgp_attr_intern (&attr); | |
fb982c25 | 3326 | |
7badc263 | 3327 | bgp_attr_dup(&new_attr, attr_new); |
fb982c25 | 3328 | |
fee0f4c6 | 3329 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3330 | ||
fb982c25 PJ |
3331 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
3332 | == RMAP_DENY) | |
3333 | { | |
fee0f4c6 | 3334 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
3335 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 3336 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 3337 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
3338 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
3339 | p->prefixlen, rsclient->host); | |
3340 | ||
3341 | bgp->peer_self->rmap_type = 0; | |
3342 | ||
f6f434b2 PJ |
3343 | bgp_attr_unintern (&attr_new); |
3344 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3345 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3346 | |
3347 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); | |
3348 | ||
3349 | return; | |
fb982c25 | 3350 | } |
fee0f4c6 | 3351 | |
3352 | bgp->peer_self->rmap_type = 0; | |
3353 | ||
f6f434b2 | 3354 | bgp_attr_unintern (&attr_new); |
fee0f4c6 | 3355 | attr_new = bgp_attr_intern (&new_attr); |
7badc263 | 3356 | bgp_attr_extra_free (&new_attr); |
fee0f4c6 | 3357 | |
3358 | for (ri = rn->info; ri; ri = ri->next) | |
3359 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3360 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3361 | break; | |
3362 | ||
3363 | if (ri) | |
3364 | { | |
8d45210e AS |
3365 | if (attrhash_cmp (ri->attr, attr_new) && |
3366 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
fee0f4c6 | 3367 | { |
3368 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3369 | bgp_attr_unintern (&attr_new); |
3370 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3371 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3372 | return; |
3373 | } | |
3374 | else | |
3375 | { | |
3376 | /* The attribute is changed. */ | |
1a392d46 | 3377 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 3378 | |
3379 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3380 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3381 | bgp_info_restore(rn, ri); | |
f6f434b2 | 3382 | bgp_attr_unintern (&ri->attr); |
fee0f4c6 | 3383 | ri->attr = attr_new; |
65957886 | 3384 | ri->uptime = bgp_clock (); |
fee0f4c6 | 3385 | |
3386 | /* Process change. */ | |
3387 | bgp_process (bgp, rn, afi, safi); | |
3388 | bgp_unlock_node (rn); | |
f6f434b2 | 3389 | aspath_unintern (&attr.aspath); |
fb982c25 | 3390 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3391 | return; |
fb982c25 | 3392 | } |
fee0f4c6 | 3393 | } |
fb982c25 | 3394 | |
fee0f4c6 | 3395 | /* Make new BGP info. */ |
3396 | new = bgp_info_new (); | |
3397 | new->type = ZEBRA_ROUTE_BGP; | |
3398 | new->sub_type = BGP_ROUTE_STATIC; | |
3399 | new->peer = bgp->peer_self; | |
3400 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3401 | new->attr = attr_new; | |
65957886 | 3402 | new->uptime = bgp_clock (); |
fee0f4c6 | 3403 | |
3404 | /* Register new BGP information. */ | |
3405 | bgp_info_add (rn, new); | |
200df115 | 3406 | |
3407 | /* route_node_get lock */ | |
3408 | bgp_unlock_node (rn); | |
3409 | ||
fee0f4c6 | 3410 | /* Process change. */ |
3411 | bgp_process (bgp, rn, afi, safi); | |
3412 | ||
3413 | /* Unintern original. */ | |
f6f434b2 | 3414 | aspath_unintern (&attr.aspath); |
fb982c25 | 3415 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3416 | } |
3417 | ||
94f2b392 | 3418 | static void |
fee0f4c6 | 3419 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
718e3744 | 3420 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
3421 | { | |
3422 | struct bgp_node *rn; | |
3423 | struct bgp_info *ri; | |
3424 | struct bgp_info *new; | |
3425 | struct bgp_info info; | |
fb982c25 | 3426 | struct attr attr = { 0 }; |
718e3744 | 3427 | struct attr *attr_new; |
3428 | int ret; | |
3429 | ||
dd8103a9 PJ |
3430 | assert (bgp_static); |
3431 | if (!bgp_static) | |
3432 | return; | |
3433 | ||
fee0f4c6 | 3434 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3435 | |
3436 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3437 | |
3438 | attr.nexthop = bgp_static->igpnexthop; | |
3439 | attr.med = bgp_static->igpmetric; | |
3440 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3441 | |
41367172 PJ |
3442 | if (bgp_static->atomic) |
3443 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3444 | ||
718e3744 | 3445 | /* Apply route-map. */ |
3446 | if (bgp_static->rmap.name) | |
3447 | { | |
fb982c25 | 3448 | struct attr attr_tmp = attr; |
718e3744 | 3449 | info.peer = bgp->peer_self; |
286e1e71 | 3450 | info.attr = &attr_tmp; |
718e3744 | 3451 | |
fee0f4c6 | 3452 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3453 | ||
718e3744 | 3454 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3455 | |
fee0f4c6 | 3456 | bgp->peer_self->rmap_type = 0; |
3457 | ||
718e3744 | 3458 | if (ret == RMAP_DENYMATCH) |
3459 | { | |
3460 | /* Free uninterned attribute. */ | |
286e1e71 | 3461 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3462 | |
3463 | /* Unintern original. */ | |
f6f434b2 | 3464 | aspath_unintern (&attr.aspath); |
fb982c25 | 3465 | bgp_attr_extra_free (&attr); |
718e3744 | 3466 | bgp_static_withdraw (bgp, p, afi, safi); |
3467 | return; | |
3468 | } | |
286e1e71 | 3469 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3470 | } |
286e1e71 | 3471 | else |
3472 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3473 | |
3474 | for (ri = rn->info; ri; ri = ri->next) | |
3475 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3476 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3477 | break; | |
3478 | ||
3479 | if (ri) | |
3480 | { | |
8d45210e AS |
3481 | if (attrhash_cmp (ri->attr, attr_new) && |
3482 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
718e3744 | 3483 | { |
3484 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3485 | bgp_attr_unintern (&attr_new); |
3486 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3487 | bgp_attr_extra_free (&attr); |
718e3744 | 3488 | return; |
3489 | } | |
3490 | else | |
3491 | { | |
3492 | /* The attribute is changed. */ | |
1a392d46 | 3493 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3494 | |
3495 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3496 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3497 | bgp_info_restore(rn, ri); | |
3498 | else | |
3499 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
f6f434b2 | 3500 | bgp_attr_unintern (&ri->attr); |
718e3744 | 3501 | ri->attr = attr_new; |
65957886 | 3502 | ri->uptime = bgp_clock (); |
718e3744 | 3503 | |
3504 | /* Process change. */ | |
3505 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3506 | bgp_process (bgp, rn, afi, safi); | |
3507 | bgp_unlock_node (rn); | |
f6f434b2 | 3508 | aspath_unintern (&attr.aspath); |
fb982c25 | 3509 | bgp_attr_extra_free (&attr); |
718e3744 | 3510 | return; |
3511 | } | |
3512 | } | |
3513 | ||
3514 | /* Make new BGP info. */ | |
3515 | new = bgp_info_new (); | |
3516 | new->type = ZEBRA_ROUTE_BGP; | |
3517 | new->sub_type = BGP_ROUTE_STATIC; | |
3518 | new->peer = bgp->peer_self; | |
3519 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3520 | new->attr = attr_new; | |
65957886 | 3521 | new->uptime = bgp_clock (); |
718e3744 | 3522 | |
3523 | /* Aggregate address increment. */ | |
3524 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3525 | ||
3526 | /* Register new BGP information. */ | |
3527 | bgp_info_add (rn, new); | |
200df115 | 3528 | |
3529 | /* route_node_get lock */ | |
3530 | bgp_unlock_node (rn); | |
3531 | ||
718e3744 | 3532 | /* Process change. */ |
3533 | bgp_process (bgp, rn, afi, safi); | |
3534 | ||
3535 | /* Unintern original. */ | |
f6f434b2 | 3536 | aspath_unintern (&attr.aspath); |
fb982c25 | 3537 | bgp_attr_extra_free (&attr); |
718e3744 | 3538 | } |
3539 | ||
fee0f4c6 | 3540 | void |
3541 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3542 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3543 | { | |
3544 | struct peer *rsclient; | |
1eb8ef25 | 3545 | struct listnode *node, *nnode; |
fee0f4c6 | 3546 | |
3547 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); | |
3548 | ||
1eb8ef25 | 3549 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 3550 | { |
da5b30f6 PJ |
3551 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
3552 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); | |
fee0f4c6 | 3553 | } |
3554 | } | |
3555 | ||
94f2b392 | 3556 | static void |
4c9641ba ML |
3557 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3558 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3559 | { |
3560 | struct bgp_node *rn; | |
3561 | struct bgp_info *new; | |
fb982c25 | 3562 | |
fee0f4c6 | 3563 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3564 | |
3565 | /* Make new BGP info. */ | |
3566 | new = bgp_info_new (); | |
3567 | new->type = ZEBRA_ROUTE_BGP; | |
3568 | new->sub_type = BGP_ROUTE_STATIC; | |
3569 | new->peer = bgp->peer_self; | |
3570 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); | |
3571 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
65957886 | 3572 | new->uptime = bgp_clock (); |
fb982c25 PJ |
3573 | new->extra = bgp_info_extra_new(); |
3574 | memcpy (new->extra->tag, tag, 3); | |
718e3744 | 3575 | |
3576 | /* Aggregate address increment. */ | |
200df115 | 3577 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
718e3744 | 3578 | |
3579 | /* Register new BGP information. */ | |
200df115 | 3580 | bgp_info_add (rn, new); |
718e3744 | 3581 | |
200df115 | 3582 | /* route_node_get lock */ |
3583 | bgp_unlock_node (rn); | |
3584 | ||
718e3744 | 3585 | /* Process change. */ |
3586 | bgp_process (bgp, rn, afi, safi); | |
3587 | } | |
3588 | ||
3589 | void | |
3590 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3591 | safi_t safi) | |
3592 | { | |
3593 | struct bgp_node *rn; | |
3594 | struct bgp_info *ri; | |
3595 | ||
fee0f4c6 | 3596 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3597 | |
3598 | /* Check selected route and self inserted route. */ | |
3599 | for (ri = rn->info; ri; ri = ri->next) | |
3600 | if (ri->peer == bgp->peer_self | |
3601 | && ri->type == ZEBRA_ROUTE_BGP | |
3602 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3603 | break; | |
3604 | ||
3605 | /* Withdraw static BGP route from routing table. */ | |
3606 | if (ri) | |
3607 | { | |
3608 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3609 | bgp_info_delete (rn, ri); |
1a392d46 | 3610 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3611 | } |
3612 | ||
3613 | /* Unlock bgp_node_lookup. */ | |
3614 | bgp_unlock_node (rn); | |
3615 | } | |
3616 | ||
fee0f4c6 | 3617 | void |
3618 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
3619 | { | |
3620 | struct bgp_static *bgp_static; | |
3621 | struct bgp *bgp; | |
3622 | struct bgp_node *rn; | |
3623 | struct prefix *p; | |
3624 | ||
3625 | bgp = rsclient->bgp; | |
3626 | ||
3627 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3628 | if ((bgp_static = rn->info) != NULL) | |
3629 | { | |
3630 | p = &rn->p; | |
3631 | ||
3632 | bgp_static_update_rsclient (rsclient, p, bgp_static, | |
3633 | afi, safi); | |
3634 | } | |
3635 | } | |
3636 | ||
94f2b392 | 3637 | static void |
4c9641ba ML |
3638 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3639 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3640 | { |
3641 | struct bgp_node *rn; | |
3642 | struct bgp_info *ri; | |
3643 | ||
fee0f4c6 | 3644 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3645 | |
3646 | /* Check selected route and self inserted route. */ | |
3647 | for (ri = rn->info; ri; ri = ri->next) | |
3648 | if (ri->peer == bgp->peer_self | |
3649 | && ri->type == ZEBRA_ROUTE_BGP | |
3650 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3651 | break; | |
3652 | ||
3653 | /* Withdraw static BGP route from routing table. */ | |
3654 | if (ri) | |
3655 | { | |
3656 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3657 | bgp_info_delete (rn, ri); |
1a392d46 | 3658 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3659 | } |
3660 | ||
3661 | /* Unlock bgp_node_lookup. */ | |
3662 | bgp_unlock_node (rn); | |
3663 | } | |
3664 | ||
3665 | /* Configure static BGP network. When user don't run zebra, static | |
3666 | route should be installed as valid. */ | |
94f2b392 | 3667 | static int |
fd79ac91 | 3668 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
c8f3fe30 | 3669 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
718e3744 | 3670 | { |
3671 | int ret; | |
3672 | struct prefix p; | |
3673 | struct bgp_static *bgp_static; | |
3674 | struct bgp_node *rn; | |
41367172 | 3675 | u_char need_update = 0; |
718e3744 | 3676 | |
3677 | /* Convert IP prefix string to struct prefix. */ | |
3678 | ret = str2prefix (ip_str, &p); | |
3679 | if (! ret) | |
3680 | { | |
3681 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3682 | return CMD_WARNING; | |
3683 | } | |
3684 | #ifdef HAVE_IPV6 | |
3685 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3686 | { | |
3687 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3688 | VTY_NEWLINE); | |
3689 | return CMD_WARNING; | |
3690 | } | |
3691 | #endif /* HAVE_IPV6 */ | |
3692 | ||
3693 | apply_mask (&p); | |
3694 | ||
3695 | /* Set BGP static route configuration. */ | |
3696 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3697 | ||
3698 | if (rn->info) | |
3699 | { | |
3700 | /* Configuration change. */ | |
3701 | bgp_static = rn->info; | |
3702 | ||
3703 | /* Check previous routes are installed into BGP. */ | |
c8f3fe30 PJ |
3704 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
3705 | need_update = 1; | |
41367172 | 3706 | |
718e3744 | 3707 | bgp_static->backdoor = backdoor; |
41367172 | 3708 | |
718e3744 | 3709 | if (rmap) |
3710 | { | |
3711 | if (bgp_static->rmap.name) | |
3712 | free (bgp_static->rmap.name); | |
3713 | bgp_static->rmap.name = strdup (rmap); | |
3714 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3715 | } | |
3716 | else | |
3717 | { | |
3718 | if (bgp_static->rmap.name) | |
3719 | free (bgp_static->rmap.name); | |
3720 | bgp_static->rmap.name = NULL; | |
3721 | bgp_static->rmap.map = NULL; | |
3722 | bgp_static->valid = 0; | |
3723 | } | |
3724 | bgp_unlock_node (rn); | |
3725 | } | |
3726 | else | |
3727 | { | |
3728 | /* New configuration. */ | |
3729 | bgp_static = bgp_static_new (); | |
3730 | bgp_static->backdoor = backdoor; | |
3731 | bgp_static->valid = 0; | |
3732 | bgp_static->igpmetric = 0; | |
3733 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 | 3734 | |
718e3744 | 3735 | if (rmap) |
3736 | { | |
3737 | if (bgp_static->rmap.name) | |
3738 | free (bgp_static->rmap.name); | |
3739 | bgp_static->rmap.name = strdup (rmap); | |
3740 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3741 | } | |
3742 | rn->info = bgp_static; | |
3743 | } | |
3744 | ||
3745 | /* If BGP scan is not enabled, we should install this route here. */ | |
3746 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3747 | { | |
3748 | bgp_static->valid = 1; | |
3749 | ||
3750 | if (need_update) | |
3751 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3752 | ||
3753 | if (! bgp_static->backdoor) | |
3754 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
3755 | } | |
3756 | ||
3757 | return CMD_SUCCESS; | |
3758 | } | |
3759 | ||
3760 | /* Configure static BGP network. */ | |
94f2b392 | 3761 | static int |
fd79ac91 | 3762 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3763 | afi_t afi, safi_t safi) |
718e3744 | 3764 | { |
3765 | int ret; | |
3766 | struct prefix p; | |
3767 | struct bgp_static *bgp_static; | |
3768 | struct bgp_node *rn; | |
3769 | ||
3770 | /* Convert IP prefix string to struct prefix. */ | |
3771 | ret = str2prefix (ip_str, &p); | |
3772 | if (! ret) | |
3773 | { | |
3774 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3775 | return CMD_WARNING; | |
3776 | } | |
3777 | #ifdef HAVE_IPV6 | |
3778 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3779 | { | |
3780 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3781 | VTY_NEWLINE); | |
3782 | return CMD_WARNING; | |
3783 | } | |
3784 | #endif /* HAVE_IPV6 */ | |
3785 | ||
3786 | apply_mask (&p); | |
3787 | ||
3788 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3789 | if (! rn) | |
3790 | { | |
3791 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3792 | VTY_NEWLINE); | |
3793 | return CMD_WARNING; | |
3794 | } | |
3795 | ||
3796 | bgp_static = rn->info; | |
41367172 | 3797 | |
718e3744 | 3798 | /* Update BGP RIB. */ |
3799 | if (! bgp_static->backdoor) | |
3800 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3801 | ||
3802 | /* Clear configuration. */ | |
3803 | bgp_static_free (bgp_static); | |
3804 | rn->info = NULL; | |
3805 | bgp_unlock_node (rn); | |
3806 | bgp_unlock_node (rn); | |
3807 | ||
3808 | return CMD_SUCCESS; | |
3809 | } | |
3810 | ||
3811 | /* Called from bgp_delete(). Delete all static routes from the BGP | |
3812 | instance. */ | |
3813 | void | |
3814 | bgp_static_delete (struct bgp *bgp) | |
3815 | { | |
3816 | afi_t afi; | |
3817 | safi_t safi; | |
3818 | struct bgp_node *rn; | |
3819 | struct bgp_node *rm; | |
3820 | struct bgp_table *table; | |
3821 | struct bgp_static *bgp_static; | |
3822 | ||
3823 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3824 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3825 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3826 | if (rn->info != NULL) | |
3827 | { | |
3828 | if (safi == SAFI_MPLS_VPN) | |
3829 | { | |
3830 | table = rn->info; | |
3831 | ||
3832 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3833 | { | |
3834 | bgp_static = rn->info; | |
3835 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, | |
3836 | AFI_IP, SAFI_MPLS_VPN, | |
3837 | (struct prefix_rd *)&rn->p, | |
3838 | bgp_static->tag); | |
3839 | bgp_static_free (bgp_static); | |
3840 | rn->info = NULL; | |
3841 | bgp_unlock_node (rn); | |
3842 | } | |
3843 | } | |
3844 | else | |
3845 | { | |
3846 | bgp_static = rn->info; | |
3847 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3848 | bgp_static_free (bgp_static); | |
3849 | rn->info = NULL; | |
3850 | bgp_unlock_node (rn); | |
3851 | } | |
3852 | } | |
3853 | } | |
3854 | ||
3855 | int | |
fd79ac91 | 3856 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
3857 | const char *tag_str) | |
718e3744 | 3858 | { |
3859 | int ret; | |
3860 | struct prefix p; | |
3861 | struct prefix_rd prd; | |
3862 | struct bgp *bgp; | |
3863 | struct bgp_node *prn; | |
3864 | struct bgp_node *rn; | |
3865 | struct bgp_table *table; | |
3866 | struct bgp_static *bgp_static; | |
3867 | u_char tag[3]; | |
3868 | ||
3869 | bgp = vty->index; | |
3870 | ||
3871 | ret = str2prefix (ip_str, &p); | |
3872 | if (! ret) | |
3873 | { | |
3874 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3875 | return CMD_WARNING; | |
3876 | } | |
3877 | apply_mask (&p); | |
3878 | ||
3879 | ret = str2prefix_rd (rd_str, &prd); | |
3880 | if (! ret) | |
3881 | { | |
3882 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3883 | return CMD_WARNING; | |
3884 | } | |
3885 | ||
3886 | ret = str2tag (tag_str, tag); | |
3887 | if (! ret) | |
3888 | { | |
3889 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3890 | return CMD_WARNING; | |
3891 | } | |
3892 | ||
3893 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3894 | (struct prefix *)&prd); | |
3895 | if (prn->info == NULL) | |
64e580a7 | 3896 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3897 | else |
3898 | bgp_unlock_node (prn); | |
3899 | table = prn->info; | |
3900 | ||
3901 | rn = bgp_node_get (table, &p); | |
3902 | ||
3903 | if (rn->info) | |
3904 | { | |
3905 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
3906 | bgp_unlock_node (rn); | |
3907 | } | |
3908 | else | |
3909 | { | |
3910 | /* New configuration. */ | |
3911 | bgp_static = bgp_static_new (); | |
3912 | bgp_static->valid = 1; | |
3913 | memcpy (bgp_static->tag, tag, 3); | |
3914 | rn->info = bgp_static; | |
3915 | ||
3916 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3917 | } | |
3918 | ||
3919 | return CMD_SUCCESS; | |
3920 | } | |
3921 | ||
3922 | /* Configure static BGP network. */ | |
3923 | int | |
fd79ac91 | 3924 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
3925 | const char *rd_str, const char *tag_str) | |
718e3744 | 3926 | { |
3927 | int ret; | |
3928 | struct bgp *bgp; | |
3929 | struct prefix p; | |
3930 | struct prefix_rd prd; | |
3931 | struct bgp_node *prn; | |
3932 | struct bgp_node *rn; | |
3933 | struct bgp_table *table; | |
3934 | struct bgp_static *bgp_static; | |
3935 | u_char tag[3]; | |
3936 | ||
3937 | bgp = vty->index; | |
3938 | ||
3939 | /* Convert IP prefix string to struct prefix. */ | |
3940 | ret = str2prefix (ip_str, &p); | |
3941 | if (! ret) | |
3942 | { | |
3943 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3944 | return CMD_WARNING; | |
3945 | } | |
3946 | apply_mask (&p); | |
3947 | ||
3948 | ret = str2prefix_rd (rd_str, &prd); | |
3949 | if (! ret) | |
3950 | { | |
3951 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3952 | return CMD_WARNING; | |
3953 | } | |
3954 | ||
3955 | ret = str2tag (tag_str, tag); | |
3956 | if (! ret) | |
3957 | { | |
3958 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3959 | return CMD_WARNING; | |
3960 | } | |
3961 | ||
3962 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3963 | (struct prefix *)&prd); | |
3964 | if (prn->info == NULL) | |
64e580a7 | 3965 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3966 | else |
3967 | bgp_unlock_node (prn); | |
3968 | table = prn->info; | |
3969 | ||
3970 | rn = bgp_node_lookup (table, &p); | |
3971 | ||
3972 | if (rn) | |
3973 | { | |
3974 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3975 | ||
3976 | bgp_static = rn->info; | |
3977 | bgp_static_free (bgp_static); | |
3978 | rn->info = NULL; | |
3979 | bgp_unlock_node (rn); | |
3980 | bgp_unlock_node (rn); | |
3981 | } | |
3982 | else | |
3983 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
3984 | ||
3985 | return CMD_SUCCESS; | |
3986 | } | |
3987 | \f | |
3988 | DEFUN (bgp_network, | |
3989 | bgp_network_cmd, | |
3990 | "network A.B.C.D/M", | |
3991 | "Specify a network to announce via BGP\n" | |
3992 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
3993 | { | |
3994 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 3995 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 3996 | } |
3997 | ||
3998 | DEFUN (bgp_network_route_map, | |
3999 | bgp_network_route_map_cmd, | |
4000 | "network A.B.C.D/M route-map WORD", | |
4001 | "Specify a network to announce via BGP\n" | |
4002 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4003 | "Route-map to modify the attributes\n" | |
4004 | "Name of the route map\n") | |
4005 | { | |
4006 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4007 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4008 | } |
4009 | ||
4010 | DEFUN (bgp_network_backdoor, | |
4011 | bgp_network_backdoor_cmd, | |
4012 | "network A.B.C.D/M backdoor", | |
4013 | "Specify a network to announce via BGP\n" | |
4014 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4015 | "Specify a BGP backdoor route\n") | |
4016 | { | |
41367172 | 4017 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4018 | NULL, 1); |
718e3744 | 4019 | } |
4020 | ||
4021 | DEFUN (bgp_network_mask, | |
4022 | bgp_network_mask_cmd, | |
4023 | "network A.B.C.D mask A.B.C.D", | |
4024 | "Specify a network to announce via BGP\n" | |
4025 | "Network number\n" | |
4026 | "Network mask\n" | |
4027 | "Network mask\n") | |
4028 | { | |
4029 | int ret; | |
4030 | char prefix_str[BUFSIZ]; | |
41367172 | 4031 | |
718e3744 | 4032 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4033 | if (! ret) | |
4034 | { | |
4035 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4036 | return CMD_WARNING; | |
4037 | } | |
4038 | ||
4039 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4040 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4041 | } |
4042 | ||
4043 | DEFUN (bgp_network_mask_route_map, | |
4044 | bgp_network_mask_route_map_cmd, | |
4045 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
4046 | "Specify a network to announce via BGP\n" | |
4047 | "Network number\n" | |
4048 | "Network mask\n" | |
4049 | "Network mask\n" | |
4050 | "Route-map to modify the attributes\n" | |
4051 | "Name of the route map\n") | |
4052 | { | |
4053 | int ret; | |
4054 | char prefix_str[BUFSIZ]; | |
41367172 | 4055 | |
718e3744 | 4056 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4057 | if (! ret) | |
4058 | { | |
4059 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4060 | return CMD_WARNING; | |
4061 | } | |
4062 | ||
4063 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4064 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
718e3744 | 4065 | } |
4066 | ||
4067 | DEFUN (bgp_network_mask_backdoor, | |
4068 | bgp_network_mask_backdoor_cmd, | |
4069 | "network A.B.C.D mask A.B.C.D backdoor", | |
4070 | "Specify a network to announce via BGP\n" | |
4071 | "Network number\n" | |
4072 | "Network mask\n" | |
4073 | "Network mask\n" | |
4074 | "Specify a BGP backdoor route\n") | |
4075 | { | |
4076 | int ret; | |
4077 | char prefix_str[BUFSIZ]; | |
41367172 | 4078 | |
718e3744 | 4079 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4080 | if (! ret) | |
4081 | { | |
4082 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4083 | return CMD_WARNING; | |
4084 | } | |
4085 | ||
41367172 | 4086 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4087 | NULL, 1); |
718e3744 | 4088 | } |
4089 | ||
4090 | DEFUN (bgp_network_mask_natural, | |
4091 | bgp_network_mask_natural_cmd, | |
4092 | "network A.B.C.D", | |
4093 | "Specify a network to announce via BGP\n" | |
4094 | "Network number\n") | |
4095 | { | |
4096 | int ret; | |
4097 | char prefix_str[BUFSIZ]; | |
4098 | ||
4099 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4100 | if (! ret) | |
4101 | { | |
4102 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4103 | return CMD_WARNING; | |
4104 | } | |
4105 | ||
4106 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4107 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4108 | } |
4109 | ||
4110 | DEFUN (bgp_network_mask_natural_route_map, | |
4111 | bgp_network_mask_natural_route_map_cmd, | |
4112 | "network A.B.C.D route-map WORD", | |
4113 | "Specify a network to announce via BGP\n" | |
4114 | "Network number\n" | |
4115 | "Route-map to modify the attributes\n" | |
4116 | "Name of the route map\n") | |
4117 | { | |
4118 | int ret; | |
4119 | char prefix_str[BUFSIZ]; | |
4120 | ||
4121 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4122 | if (! ret) | |
4123 | { | |
4124 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4125 | return CMD_WARNING; | |
4126 | } | |
4127 | ||
4128 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4129 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4130 | } |
4131 | ||
4132 | DEFUN (bgp_network_mask_natural_backdoor, | |
4133 | bgp_network_mask_natural_backdoor_cmd, | |
4134 | "network A.B.C.D backdoor", | |
4135 | "Specify a network to announce via BGP\n" | |
4136 | "Network number\n" | |
4137 | "Specify a BGP backdoor route\n") | |
4138 | { | |
4139 | int ret; | |
4140 | char prefix_str[BUFSIZ]; | |
4141 | ||
4142 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4143 | if (! ret) | |
4144 | { | |
4145 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4146 | return CMD_WARNING; | |
4147 | } | |
4148 | ||
41367172 | 4149 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4150 | NULL, 1); |
718e3744 | 4151 | } |
4152 | ||
4153 | DEFUN (no_bgp_network, | |
4154 | no_bgp_network_cmd, | |
4155 | "no network A.B.C.D/M", | |
4156 | NO_STR | |
4157 | "Specify a network to announce via BGP\n" | |
4158 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4159 | { | |
4160 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4161 | bgp_node_safi (vty)); | |
4162 | } | |
4163 | ||
4164 | ALIAS (no_bgp_network, | |
4165 | no_bgp_network_route_map_cmd, | |
4166 | "no network A.B.C.D/M route-map WORD", | |
4167 | NO_STR | |
4168 | "Specify a network to announce via BGP\n" | |
4169 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4170 | "Route-map to modify the attributes\n" | |
4171 | "Name of the route map\n") | |
4172 | ||
4173 | ALIAS (no_bgp_network, | |
4174 | no_bgp_network_backdoor_cmd, | |
4175 | "no network A.B.C.D/M backdoor", | |
4176 | NO_STR | |
4177 | "Specify a network to announce via BGP\n" | |
4178 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4179 | "Specify a BGP backdoor route\n") | |
4180 | ||
4181 | DEFUN (no_bgp_network_mask, | |
4182 | no_bgp_network_mask_cmd, | |
4183 | "no network A.B.C.D mask A.B.C.D", | |
4184 | NO_STR | |
4185 | "Specify a network to announce via BGP\n" | |
4186 | "Network number\n" | |
4187 | "Network mask\n" | |
4188 | "Network mask\n") | |
4189 | { | |
4190 | int ret; | |
4191 | char prefix_str[BUFSIZ]; | |
4192 | ||
4193 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4194 | if (! ret) | |
4195 | { | |
4196 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4197 | return CMD_WARNING; | |
4198 | } | |
4199 | ||
4200 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4201 | bgp_node_safi (vty)); | |
4202 | } | |
4203 | ||
4204 | ALIAS (no_bgp_network_mask, | |
4205 | no_bgp_network_mask_route_map_cmd, | |
4206 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4207 | NO_STR | |
4208 | "Specify a network to announce via BGP\n" | |
4209 | "Network number\n" | |
4210 | "Network mask\n" | |
4211 | "Network mask\n" | |
4212 | "Route-map to modify the attributes\n" | |
4213 | "Name of the route map\n") | |
4214 | ||
4215 | ALIAS (no_bgp_network_mask, | |
4216 | no_bgp_network_mask_backdoor_cmd, | |
4217 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4218 | NO_STR | |
4219 | "Specify a network to announce via BGP\n" | |
4220 | "Network number\n" | |
4221 | "Network mask\n" | |
4222 | "Network mask\n" | |
4223 | "Specify a BGP backdoor route\n") | |
4224 | ||
4225 | DEFUN (no_bgp_network_mask_natural, | |
4226 | no_bgp_network_mask_natural_cmd, | |
4227 | "no network A.B.C.D", | |
4228 | NO_STR | |
4229 | "Specify a network to announce via BGP\n" | |
4230 | "Network number\n") | |
4231 | { | |
4232 | int ret; | |
4233 | char prefix_str[BUFSIZ]; | |
4234 | ||
4235 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4236 | if (! ret) | |
4237 | { | |
4238 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4239 | return CMD_WARNING; | |
4240 | } | |
4241 | ||
4242 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4243 | bgp_node_safi (vty)); | |
4244 | } | |
4245 | ||
4246 | ALIAS (no_bgp_network_mask_natural, | |
4247 | no_bgp_network_mask_natural_route_map_cmd, | |
4248 | "no network A.B.C.D route-map WORD", | |
4249 | NO_STR | |
4250 | "Specify a network to announce via BGP\n" | |
4251 | "Network number\n" | |
4252 | "Route-map to modify the attributes\n" | |
4253 | "Name of the route map\n") | |
4254 | ||
4255 | ALIAS (no_bgp_network_mask_natural, | |
4256 | no_bgp_network_mask_natural_backdoor_cmd, | |
4257 | "no network A.B.C.D backdoor", | |
4258 | NO_STR | |
4259 | "Specify a network to announce via BGP\n" | |
4260 | "Network number\n" | |
4261 | "Specify a BGP backdoor route\n") | |
4262 | ||
4263 | #ifdef HAVE_IPV6 | |
4264 | DEFUN (ipv6_bgp_network, | |
4265 | ipv6_bgp_network_cmd, | |
4266 | "network X:X::X:X/M", | |
4267 | "Specify a network to announce via BGP\n" | |
4268 | "IPv6 prefix <network>/<length>\n") | |
4269 | { | |
73bfe0bd | 4270 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), |
c8f3fe30 | 4271 | NULL, 0); |
718e3744 | 4272 | } |
4273 | ||
4274 | DEFUN (ipv6_bgp_network_route_map, | |
4275 | ipv6_bgp_network_route_map_cmd, | |
4276 | "network X:X::X:X/M route-map WORD", | |
4277 | "Specify a network to announce via BGP\n" | |
4278 | "IPv6 prefix <network>/<length>\n" | |
4279 | "Route-map to modify the attributes\n" | |
4280 | "Name of the route map\n") | |
4281 | { | |
4282 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
c8f3fe30 | 4283 | bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4284 | } |
4285 | ||
4286 | DEFUN (no_ipv6_bgp_network, | |
4287 | no_ipv6_bgp_network_cmd, | |
4288 | "no network X:X::X:X/M", | |
4289 | NO_STR | |
4290 | "Specify a network to announce via BGP\n" | |
4291 | "IPv6 prefix <network>/<length>\n") | |
4292 | { | |
73bfe0bd | 4293 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); |
718e3744 | 4294 | } |
4295 | ||
4296 | ALIAS (no_ipv6_bgp_network, | |
4297 | no_ipv6_bgp_network_route_map_cmd, | |
4298 | "no network X:X::X:X/M route-map WORD", | |
4299 | NO_STR | |
4300 | "Specify a network to announce via BGP\n" | |
4301 | "IPv6 prefix <network>/<length>\n" | |
4302 | "Route-map to modify the attributes\n" | |
4303 | "Name of the route map\n") | |
4304 | ||
4305 | ALIAS (ipv6_bgp_network, | |
4306 | old_ipv6_bgp_network_cmd, | |
4307 | "ipv6 bgp network X:X::X:X/M", | |
4308 | IPV6_STR | |
4309 | BGP_STR | |
4310 | "Specify a network to announce via BGP\n" | |
4311 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4312 | ||
4313 | ALIAS (no_ipv6_bgp_network, | |
4314 | old_no_ipv6_bgp_network_cmd, | |
4315 | "no ipv6 bgp network X:X::X:X/M", | |
4316 | NO_STR | |
4317 | IPV6_STR | |
4318 | BGP_STR | |
4319 | "Specify a network to announce via BGP\n" | |
4320 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4321 | #endif /* HAVE_IPV6 */ | |
c8f3fe30 PJ |
4322 | |
4323 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ | |
4324 | ALIAS_DEPRECATED (bgp_network, | |
4325 | bgp_network_ttl_cmd, | |
4326 | "network A.B.C.D/M pathlimit <0-255>", | |
4327 | "Specify a network to announce via BGP\n" | |
4328 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4329 | "AS-Path hopcount limit attribute\n" | |
4330 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4331 | ALIAS_DEPRECATED (bgp_network_backdoor, | |
4332 | bgp_network_backdoor_ttl_cmd, | |
4333 | "network A.B.C.D/M backdoor pathlimit <0-255>", | |
4334 | "Specify a network to announce via BGP\n" | |
4335 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4336 | "Specify a BGP backdoor route\n" | |
4337 | "AS-Path hopcount limit attribute\n" | |
4338 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4339 | ALIAS_DEPRECATED (bgp_network_mask, | |
4340 | bgp_network_mask_ttl_cmd, | |
4341 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4342 | "Specify a network to announce via BGP\n" | |
4343 | "Network number\n" | |
4344 | "Network mask\n" | |
4345 | "Network mask\n" | |
4346 | "AS-Path hopcount limit attribute\n" | |
4347 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4348 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, | |
4349 | bgp_network_mask_backdoor_ttl_cmd, | |
4350 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4351 | "Specify a network to announce via BGP\n" | |
4352 | "Network number\n" | |
4353 | "Network mask\n" | |
4354 | "Network mask\n" | |
4355 | "Specify a BGP backdoor route\n" | |
4356 | "AS-Path hopcount limit attribute\n" | |
4357 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4358 | ALIAS_DEPRECATED (bgp_network_mask_natural, | |
4359 | bgp_network_mask_natural_ttl_cmd, | |
4360 | "network A.B.C.D pathlimit <0-255>", | |
4361 | "Specify a network to announce via BGP\n" | |
4362 | "Network number\n" | |
4363 | "AS-Path hopcount limit attribute\n" | |
4364 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4365 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, | |
4366 | bgp_network_mask_natural_backdoor_ttl_cmd, | |
4367 | "network A.B.C.D backdoor pathlimit (1-255>", | |
4368 | "Specify a network to announce via BGP\n" | |
4369 | "Network number\n" | |
4370 | "Specify a BGP backdoor route\n" | |
4371 | "AS-Path hopcount limit attribute\n" | |
4372 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4373 | ALIAS_DEPRECATED (no_bgp_network, | |
4374 | no_bgp_network_ttl_cmd, | |
4375 | "no network A.B.C.D/M pathlimit <0-255>", | |
4376 | NO_STR | |
4377 | "Specify a network to announce via BGP\n" | |
4378 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4379 | "AS-Path hopcount limit attribute\n" | |
4380 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4381 | ALIAS_DEPRECATED (no_bgp_network, | |
4382 | no_bgp_network_backdoor_ttl_cmd, | |
4383 | "no network A.B.C.D/M backdoor pathlimit <0-255>", | |
4384 | NO_STR | |
4385 | "Specify a network to announce via BGP\n" | |
4386 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4387 | "Specify a BGP backdoor route\n" | |
4388 | "AS-Path hopcount limit attribute\n" | |
4389 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4390 | ALIAS_DEPRECATED (no_bgp_network, | |
4391 | no_bgp_network_mask_ttl_cmd, | |
4392 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4393 | NO_STR | |
4394 | "Specify a network to announce via BGP\n" | |
4395 | "Network number\n" | |
4396 | "Network mask\n" | |
4397 | "Network mask\n" | |
4398 | "AS-Path hopcount limit attribute\n" | |
4399 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4400 | ALIAS_DEPRECATED (no_bgp_network_mask, | |
4401 | no_bgp_network_mask_backdoor_ttl_cmd, | |
4402 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4403 | NO_STR | |
4404 | "Specify a network to announce via BGP\n" | |
4405 | "Network number\n" | |
4406 | "Network mask\n" | |
4407 | "Network mask\n" | |
4408 | "Specify a BGP backdoor route\n" | |
4409 | "AS-Path hopcount limit attribute\n" | |
4410 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4411 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, | |
4412 | no_bgp_network_mask_natural_ttl_cmd, | |
4413 | "no network A.B.C.D pathlimit <0-255>", | |
4414 | NO_STR | |
4415 | "Specify a network to announce via BGP\n" | |
4416 | "Network number\n" | |
4417 | "AS-Path hopcount limit attribute\n" | |
4418 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4419 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, | |
4420 | no_bgp_network_mask_natural_backdoor_ttl_cmd, | |
4421 | "no network A.B.C.D backdoor pathlimit <0-255>", | |
4422 | NO_STR | |
4423 | "Specify a network to announce via BGP\n" | |
4424 | "Network number\n" | |
4425 | "Specify a BGP backdoor route\n" | |
4426 | "AS-Path hopcount limit attribute\n" | |
4427 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
3bde17f1 | 4428 | #ifdef HAVE_IPV6 |
c8f3fe30 PJ |
4429 | ALIAS_DEPRECATED (ipv6_bgp_network, |
4430 | ipv6_bgp_network_ttl_cmd, | |
4431 | "network X:X::X:X/M pathlimit <0-255>", | |
4432 | "Specify a network to announce via BGP\n" | |
4433 | "IPv6 prefix <network>/<length>\n" | |
4434 | "AS-Path hopcount limit attribute\n" | |
4435 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4436 | ALIAS_DEPRECATED (no_ipv6_bgp_network, | |
4437 | no_ipv6_bgp_network_ttl_cmd, | |
4438 | "no network X:X::X:X/M pathlimit <0-255>", | |
4439 | NO_STR | |
4440 | "Specify a network to announce via BGP\n" | |
4441 | "IPv6 prefix <network>/<length>\n" | |
4442 | "AS-Path hopcount limit attribute\n" | |
4443 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
3bde17f1 | 4444 | #endif /* HAVE_IPV6 */ |
718e3744 | 4445 | \f |
4446 | /* Aggreagete address: | |
4447 | ||
4448 | advertise-map Set condition to advertise attribute | |
4449 | as-set Generate AS set path information | |
4450 | attribute-map Set attributes of aggregate | |
4451 | route-map Set parameters of aggregate | |
4452 | summary-only Filter more specific routes from updates | |
4453 | suppress-map Conditionally filter more specific routes from updates | |
4454 | <cr> | |
4455 | */ | |
4456 | struct bgp_aggregate | |
4457 | { | |
4458 | /* Summary-only flag. */ | |
4459 | u_char summary_only; | |
4460 | ||
4461 | /* AS set generation. */ | |
4462 | u_char as_set; | |
4463 | ||
4464 | /* Route-map for aggregated route. */ | |
4465 | struct route_map *map; | |
4466 | ||
4467 | /* Suppress-count. */ | |
4468 | unsigned long count; | |
4469 | ||
4470 | /* SAFI configuration. */ | |
4471 | safi_t safi; | |
4472 | }; | |
4473 | ||
94f2b392 | 4474 | static struct bgp_aggregate * |
66e5cd87 | 4475 | bgp_aggregate_new (void) |
718e3744 | 4476 | { |
393deb9b | 4477 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4478 | } |
4479 | ||
94f2b392 | 4480 | static void |
718e3744 | 4481 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4482 | { | |
4483 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4484 | } | |
4485 | ||
94f2b392 | 4486 | static void |
718e3744 | 4487 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4488 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4489 | struct bgp_aggregate *aggregate) | |
4490 | { | |
4491 | struct bgp_table *table; | |
4492 | struct bgp_node *top; | |
4493 | struct bgp_node *rn; | |
4494 | u_char origin; | |
4495 | struct aspath *aspath = NULL; | |
4496 | struct aspath *asmerge = NULL; | |
4497 | struct community *community = NULL; | |
4498 | struct community *commerge = NULL; | |
4499 | struct in_addr nexthop; | |
4500 | u_int32_t med = 0; | |
4501 | struct bgp_info *ri; | |
4502 | struct bgp_info *new; | |
4503 | int first = 1; | |
4504 | unsigned long match = 0; | |
4505 | ||
4506 | /* Record adding route's nexthop and med. */ | |
4507 | if (rinew) | |
4508 | { | |
4509 | nexthop = rinew->attr->nexthop; | |
4510 | med = rinew->attr->med; | |
4511 | } | |
4512 | ||
4513 | /* ORIGIN attribute: If at least one route among routes that are | |
4514 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4515 | aggregated route must have the ORIGIN attribute with the value | |
4516 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4517 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4518 | route must have the origin attribute with the value EGP. In all | |
4519 | other case the value of the ORIGIN attribute of the aggregated | |
4520 | route is INTERNAL. */ | |
4521 | origin = BGP_ORIGIN_IGP; | |
4522 | ||
4523 | table = bgp->rib[afi][safi]; | |
4524 | ||
4525 | top = bgp_node_get (table, p); | |
4526 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4527 | if (rn->p.prefixlen > p->prefixlen) | |
4528 | { | |
4529 | match = 0; | |
4530 | ||
4531 | for (ri = rn->info; ri; ri = ri->next) | |
4532 | { | |
4533 | if (BGP_INFO_HOLDDOWN (ri)) | |
4534 | continue; | |
4535 | ||
4536 | if (del && ri == del) | |
4537 | continue; | |
4538 | ||
4539 | if (! rinew && first) | |
4540 | { | |
4541 | nexthop = ri->attr->nexthop; | |
4542 | med = ri->attr->med; | |
4543 | first = 0; | |
4544 | } | |
4545 | ||
4546 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4547 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4548 | || ri->attr->med != med) | |
4549 | { | |
4550 | if (aspath) | |
4551 | aspath_free (aspath); | |
4552 | if (community) | |
4553 | community_free (community); | |
4554 | bgp_unlock_node (rn); | |
4555 | bgp_unlock_node (top); | |
4556 | return; | |
4557 | } | |
4558 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4559 | ||
4560 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4561 | { | |
4562 | if (aggregate->summary_only) | |
4563 | { | |
fb982c25 | 4564 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4565 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4566 | match++; |
4567 | } | |
4568 | ||
4569 | aggregate->count++; | |
4570 | ||
4571 | if (aggregate->as_set) | |
4572 | { | |
4573 | if (origin < ri->attr->origin) | |
4574 | origin = ri->attr->origin; | |
4575 | ||
4576 | if (aspath) | |
4577 | { | |
4578 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4579 | aspath_free (aspath); | |
4580 | aspath = asmerge; | |
4581 | } | |
4582 | else | |
4583 | aspath = aspath_dup (ri->attr->aspath); | |
4584 | ||
4585 | if (ri->attr->community) | |
4586 | { | |
4587 | if (community) | |
4588 | { | |
4589 | commerge = community_merge (community, | |
4590 | ri->attr->community); | |
4591 | community = community_uniq_sort (commerge); | |
4592 | community_free (commerge); | |
4593 | } | |
4594 | else | |
4595 | community = community_dup (ri->attr->community); | |
4596 | } | |
4597 | } | |
4598 | } | |
4599 | } | |
4600 | if (match) | |
4601 | bgp_process (bgp, rn, afi, safi); | |
4602 | } | |
4603 | bgp_unlock_node (top); | |
4604 | ||
4605 | if (rinew) | |
4606 | { | |
4607 | aggregate->count++; | |
4608 | ||
4609 | if (aggregate->summary_only) | |
fb982c25 | 4610 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4611 | |
4612 | if (aggregate->as_set) | |
4613 | { | |
4614 | if (origin < rinew->attr->origin) | |
4615 | origin = rinew->attr->origin; | |
4616 | ||
4617 | if (aspath) | |
4618 | { | |
4619 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4620 | aspath_free (aspath); | |
4621 | aspath = asmerge; | |
4622 | } | |
4623 | else | |
4624 | aspath = aspath_dup (rinew->attr->aspath); | |
4625 | ||
4626 | if (rinew->attr->community) | |
4627 | { | |
4628 | if (community) | |
4629 | { | |
4630 | commerge = community_merge (community, | |
4631 | rinew->attr->community); | |
4632 | community = community_uniq_sort (commerge); | |
4633 | community_free (commerge); | |
4634 | } | |
4635 | else | |
4636 | community = community_dup (rinew->attr->community); | |
4637 | } | |
4638 | } | |
4639 | } | |
4640 | ||
4641 | if (aggregate->count > 0) | |
4642 | { | |
4643 | rn = bgp_node_get (table, p); | |
4644 | new = bgp_info_new (); | |
4645 | new->type = ZEBRA_ROUTE_BGP; | |
4646 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4647 | new->peer = bgp->peer_self; | |
4648 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4649 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4650 | new->uptime = bgp_clock (); |
718e3744 | 4651 | |
4652 | bgp_info_add (rn, new); | |
200df115 | 4653 | bgp_unlock_node (rn); |
718e3744 | 4654 | bgp_process (bgp, rn, afi, safi); |
4655 | } | |
4656 | else | |
4657 | { | |
4658 | if (aspath) | |
4659 | aspath_free (aspath); | |
4660 | if (community) | |
4661 | community_free (community); | |
4662 | } | |
4663 | } | |
4664 | ||
4665 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4666 | struct bgp_aggregate *); | |
4667 | ||
4668 | void | |
4669 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4670 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4671 | { | |
4672 | struct bgp_node *child; | |
4673 | struct bgp_node *rn; | |
4674 | struct bgp_aggregate *aggregate; | |
4675 | ||
4676 | /* MPLS-VPN aggregation is not yet supported. */ | |
4677 | if (safi == SAFI_MPLS_VPN) | |
4678 | return; | |
4679 | ||
4680 | if (p->prefixlen == 0) | |
4681 | return; | |
4682 | ||
4683 | if (BGP_INFO_HOLDDOWN (ri)) | |
4684 | return; | |
4685 | ||
4686 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4687 | ||
4688 | /* Aggregate address configuration check. */ | |
4689 | for (rn = child; rn; rn = rn->parent) | |
4690 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4691 | { | |
4692 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4693 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4694 | } |
4695 | bgp_unlock_node (child); | |
4696 | } | |
4697 | ||
4698 | void | |
4699 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4700 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4701 | { | |
4702 | struct bgp_node *child; | |
4703 | struct bgp_node *rn; | |
4704 | struct bgp_aggregate *aggregate; | |
4705 | ||
4706 | /* MPLS-VPN aggregation is not yet supported. */ | |
4707 | if (safi == SAFI_MPLS_VPN) | |
4708 | return; | |
4709 | ||
4710 | if (p->prefixlen == 0) | |
4711 | return; | |
4712 | ||
4713 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4714 | ||
4715 | /* Aggregate address configuration check. */ | |
4716 | for (rn = child; rn; rn = rn->parent) | |
4717 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4718 | { | |
4719 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4720 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4721 | } |
4722 | bgp_unlock_node (child); | |
4723 | } | |
4724 | ||
94f2b392 | 4725 | static void |
718e3744 | 4726 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4727 | struct bgp_aggregate *aggregate) | |
4728 | { | |
4729 | struct bgp_table *table; | |
4730 | struct bgp_node *top; | |
4731 | struct bgp_node *rn; | |
4732 | struct bgp_info *new; | |
4733 | struct bgp_info *ri; | |
4734 | unsigned long match; | |
4735 | u_char origin = BGP_ORIGIN_IGP; | |
4736 | struct aspath *aspath = NULL; | |
4737 | struct aspath *asmerge = NULL; | |
4738 | struct community *community = NULL; | |
4739 | struct community *commerge = NULL; | |
4740 | ||
4741 | table = bgp->rib[afi][safi]; | |
4742 | ||
4743 | /* Sanity check. */ | |
4744 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4745 | return; | |
4746 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4747 | return; | |
4748 | ||
4749 | /* If routes exists below this node, generate aggregate routes. */ | |
4750 | top = bgp_node_get (table, p); | |
4751 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4752 | if (rn->p.prefixlen > p->prefixlen) | |
4753 | { | |
4754 | match = 0; | |
4755 | ||
4756 | for (ri = rn->info; ri; ri = ri->next) | |
4757 | { | |
4758 | if (BGP_INFO_HOLDDOWN (ri)) | |
4759 | continue; | |
4760 | ||
4761 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4762 | { | |
4763 | /* summary-only aggregate route suppress aggregated | |
4764 | route announcement. */ | |
4765 | if (aggregate->summary_only) | |
4766 | { | |
fb982c25 | 4767 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4768 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4769 | match++; |
4770 | } | |
4771 | /* as-set aggregate route generate origin, as path, | |
4772 | community aggregation. */ | |
4773 | if (aggregate->as_set) | |
4774 | { | |
4775 | if (origin < ri->attr->origin) | |
4776 | origin = ri->attr->origin; | |
4777 | ||
4778 | if (aspath) | |
4779 | { | |
4780 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4781 | aspath_free (aspath); | |
4782 | aspath = asmerge; | |
4783 | } | |
4784 | else | |
4785 | aspath = aspath_dup (ri->attr->aspath); | |
4786 | ||
4787 | if (ri->attr->community) | |
4788 | { | |
4789 | if (community) | |
4790 | { | |
4791 | commerge = community_merge (community, | |
4792 | ri->attr->community); | |
4793 | community = community_uniq_sort (commerge); | |
4794 | community_free (commerge); | |
4795 | } | |
4796 | else | |
4797 | community = community_dup (ri->attr->community); | |
4798 | } | |
4799 | } | |
4800 | aggregate->count++; | |
4801 | } | |
4802 | } | |
4803 | ||
4804 | /* If this node is suppressed, process the change. */ | |
4805 | if (match) | |
4806 | bgp_process (bgp, rn, afi, safi); | |
4807 | } | |
4808 | bgp_unlock_node (top); | |
4809 | ||
4810 | /* Add aggregate route to BGP table. */ | |
4811 | if (aggregate->count) | |
4812 | { | |
4813 | rn = bgp_node_get (table, p); | |
4814 | ||
4815 | new = bgp_info_new (); | |
4816 | new->type = ZEBRA_ROUTE_BGP; | |
4817 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4818 | new->peer = bgp->peer_self; | |
4819 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4820 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4821 | new->uptime = bgp_clock (); |
718e3744 | 4822 | |
4823 | bgp_info_add (rn, new); | |
200df115 | 4824 | bgp_unlock_node (rn); |
4825 | ||
718e3744 | 4826 | /* Process change. */ |
4827 | bgp_process (bgp, rn, afi, safi); | |
4828 | } | |
4829 | } | |
4830 | ||
4831 | void | |
4832 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
4833 | safi_t safi, struct bgp_aggregate *aggregate) | |
4834 | { | |
4835 | struct bgp_table *table; | |
4836 | struct bgp_node *top; | |
4837 | struct bgp_node *rn; | |
4838 | struct bgp_info *ri; | |
4839 | unsigned long match; | |
4840 | ||
4841 | table = bgp->rib[afi][safi]; | |
4842 | ||
4843 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4844 | return; | |
4845 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4846 | return; | |
4847 | ||
4848 | /* If routes exists below this node, generate aggregate routes. */ | |
4849 | top = bgp_node_get (table, p); | |
4850 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4851 | if (rn->p.prefixlen > p->prefixlen) | |
4852 | { | |
4853 | match = 0; | |
4854 | ||
4855 | for (ri = rn->info; ri; ri = ri->next) | |
4856 | { | |
4857 | if (BGP_INFO_HOLDDOWN (ri)) | |
4858 | continue; | |
4859 | ||
4860 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4861 | { | |
fb982c25 | 4862 | if (aggregate->summary_only && ri->extra) |
718e3744 | 4863 | { |
fb982c25 | 4864 | ri->extra->suppress--; |
718e3744 | 4865 | |
fb982c25 | 4866 | if (ri->extra->suppress == 0) |
718e3744 | 4867 | { |
1a392d46 | 4868 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4869 | match++; |
4870 | } | |
4871 | } | |
4872 | aggregate->count--; | |
4873 | } | |
4874 | } | |
4875 | ||
fb982c25 | 4876 | /* If this node was suppressed, process the change. */ |
718e3744 | 4877 | if (match) |
4878 | bgp_process (bgp, rn, afi, safi); | |
4879 | } | |
4880 | bgp_unlock_node (top); | |
4881 | ||
4882 | /* Delete aggregate route from BGP table. */ | |
4883 | rn = bgp_node_get (table, p); | |
4884 | ||
4885 | for (ri = rn->info; ri; ri = ri->next) | |
4886 | if (ri->peer == bgp->peer_self | |
4887 | && ri->type == ZEBRA_ROUTE_BGP | |
4888 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
4889 | break; | |
4890 | ||
4891 | /* Withdraw static BGP route from routing table. */ | |
4892 | if (ri) | |
4893 | { | |
718e3744 | 4894 | bgp_info_delete (rn, ri); |
1a392d46 | 4895 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 4896 | } |
4897 | ||
4898 | /* Unlock bgp_node_lookup. */ | |
4899 | bgp_unlock_node (rn); | |
4900 | } | |
4901 | ||
4902 | /* Aggregate route attribute. */ | |
4903 | #define AGGREGATE_SUMMARY_ONLY 1 | |
4904 | #define AGGREGATE_AS_SET 1 | |
4905 | ||
94f2b392 | 4906 | static int |
f6269b4f RB |
4907 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
4908 | afi_t afi, safi_t safi) | |
718e3744 | 4909 | { |
4910 | int ret; | |
4911 | struct prefix p; | |
4912 | struct bgp_node *rn; | |
4913 | struct bgp *bgp; | |
4914 | struct bgp_aggregate *aggregate; | |
4915 | ||
4916 | /* Convert string to prefix structure. */ | |
4917 | ret = str2prefix (prefix_str, &p); | |
4918 | if (!ret) | |
4919 | { | |
4920 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4921 | return CMD_WARNING; | |
4922 | } | |
4923 | apply_mask (&p); | |
4924 | ||
4925 | /* Get BGP structure. */ | |
4926 | bgp = vty->index; | |
4927 | ||
4928 | /* Old configuration check. */ | |
f6269b4f RB |
4929 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
4930 | if (! rn) | |
718e3744 | 4931 | { |
f6269b4f RB |
4932 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
4933 | VTY_NEWLINE); | |
718e3744 | 4934 | return CMD_WARNING; |
4935 | } | |
4936 | ||
f6269b4f RB |
4937 | aggregate = rn->info; |
4938 | if (aggregate->safi & SAFI_UNICAST) | |
4939 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4940 | if (aggregate->safi & SAFI_MULTICAST) | |
4941 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4942 | |
f6269b4f RB |
4943 | /* Unlock aggregate address configuration. */ |
4944 | rn->info = NULL; | |
4945 | bgp_aggregate_free (aggregate); | |
4946 | bgp_unlock_node (rn); | |
4947 | bgp_unlock_node (rn); | |
718e3744 | 4948 | |
4949 | return CMD_SUCCESS; | |
4950 | } | |
4951 | ||
94f2b392 | 4952 | static int |
f6269b4f RB |
4953 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
4954 | afi_t afi, safi_t safi, | |
4955 | u_char summary_only, u_char as_set) | |
718e3744 | 4956 | { |
4957 | int ret; | |
4958 | struct prefix p; | |
4959 | struct bgp_node *rn; | |
4960 | struct bgp *bgp; | |
4961 | struct bgp_aggregate *aggregate; | |
4962 | ||
4963 | /* Convert string to prefix structure. */ | |
4964 | ret = str2prefix (prefix_str, &p); | |
4965 | if (!ret) | |
4966 | { | |
4967 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4968 | return CMD_WARNING; | |
4969 | } | |
4970 | apply_mask (&p); | |
4971 | ||
4972 | /* Get BGP structure. */ | |
4973 | bgp = vty->index; | |
4974 | ||
4975 | /* Old configuration check. */ | |
f6269b4f RB |
4976 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
4977 | ||
4978 | if (rn->info) | |
718e3744 | 4979 | { |
f6269b4f | 4980 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
368473f6 | 4981 | /* try to remove the old entry */ |
f6269b4f RB |
4982 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
4983 | if (ret) | |
4984 | { | |
368473f6 RB |
4985 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
4986 | bgp_unlock_node (rn); | |
f6269b4f RB |
4987 | return CMD_WARNING; |
4988 | } | |
718e3744 | 4989 | } |
4990 | ||
f6269b4f RB |
4991 | /* Make aggregate address structure. */ |
4992 | aggregate = bgp_aggregate_new (); | |
4993 | aggregate->summary_only = summary_only; | |
4994 | aggregate->as_set = as_set; | |
4995 | aggregate->safi = safi; | |
4996 | rn->info = aggregate; | |
718e3744 | 4997 | |
f6269b4f RB |
4998 | /* Aggregate address insert into BGP routing table. */ |
4999 | if (safi & SAFI_UNICAST) | |
5000 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5001 | if (safi & SAFI_MULTICAST) | |
5002 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 5003 | |
5004 | return CMD_SUCCESS; | |
5005 | } | |
5006 | ||
5007 | DEFUN (aggregate_address, | |
5008 | aggregate_address_cmd, | |
5009 | "aggregate-address A.B.C.D/M", | |
5010 | "Configure BGP aggregate entries\n" | |
5011 | "Aggregate prefix\n") | |
5012 | { | |
5013 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
5014 | } | |
5015 | ||
5016 | DEFUN (aggregate_address_mask, | |
5017 | aggregate_address_mask_cmd, | |
5018 | "aggregate-address A.B.C.D A.B.C.D", | |
5019 | "Configure BGP aggregate entries\n" | |
5020 | "Aggregate address\n" | |
5021 | "Aggregate mask\n") | |
5022 | { | |
5023 | int ret; | |
5024 | char prefix_str[BUFSIZ]; | |
5025 | ||
5026 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5027 | ||
5028 | if (! ret) | |
5029 | { | |
5030 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5031 | return CMD_WARNING; | |
5032 | } | |
5033 | ||
5034 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5035 | 0, 0); | |
5036 | } | |
5037 | ||
5038 | DEFUN (aggregate_address_summary_only, | |
5039 | aggregate_address_summary_only_cmd, | |
5040 | "aggregate-address A.B.C.D/M summary-only", | |
5041 | "Configure BGP aggregate entries\n" | |
5042 | "Aggregate prefix\n" | |
5043 | "Filter more specific routes from updates\n") | |
5044 | { | |
5045 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5046 | AGGREGATE_SUMMARY_ONLY, 0); | |
5047 | } | |
5048 | ||
5049 | DEFUN (aggregate_address_mask_summary_only, | |
5050 | aggregate_address_mask_summary_only_cmd, | |
5051 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
5052 | "Configure BGP aggregate entries\n" | |
5053 | "Aggregate address\n" | |
5054 | "Aggregate mask\n" | |
5055 | "Filter more specific routes from updates\n") | |
5056 | { | |
5057 | int ret; | |
5058 | char prefix_str[BUFSIZ]; | |
5059 | ||
5060 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5061 | ||
5062 | if (! ret) | |
5063 | { | |
5064 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5065 | return CMD_WARNING; | |
5066 | } | |
5067 | ||
5068 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5069 | AGGREGATE_SUMMARY_ONLY, 0); | |
5070 | } | |
5071 | ||
5072 | DEFUN (aggregate_address_as_set, | |
5073 | aggregate_address_as_set_cmd, | |
5074 | "aggregate-address A.B.C.D/M as-set", | |
5075 | "Configure BGP aggregate entries\n" | |
5076 | "Aggregate prefix\n" | |
5077 | "Generate AS set path information\n") | |
5078 | { | |
5079 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5080 | 0, AGGREGATE_AS_SET); | |
5081 | } | |
5082 | ||
5083 | DEFUN (aggregate_address_mask_as_set, | |
5084 | aggregate_address_mask_as_set_cmd, | |
5085 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
5086 | "Configure BGP aggregate entries\n" | |
5087 | "Aggregate address\n" | |
5088 | "Aggregate mask\n" | |
5089 | "Generate AS set path information\n") | |
5090 | { | |
5091 | int ret; | |
5092 | char prefix_str[BUFSIZ]; | |
5093 | ||
5094 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5095 | ||
5096 | if (! ret) | |
5097 | { | |
5098 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5099 | return CMD_WARNING; | |
5100 | } | |
5101 | ||
5102 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5103 | 0, AGGREGATE_AS_SET); | |
5104 | } | |
5105 | ||
5106 | ||
5107 | DEFUN (aggregate_address_as_set_summary, | |
5108 | aggregate_address_as_set_summary_cmd, | |
5109 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5110 | "Configure BGP aggregate entries\n" | |
5111 | "Aggregate prefix\n" | |
5112 | "Generate AS set path information\n" | |
5113 | "Filter more specific routes from updates\n") | |
5114 | { | |
5115 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5116 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5117 | } | |
5118 | ||
5119 | ALIAS (aggregate_address_as_set_summary, | |
5120 | aggregate_address_summary_as_set_cmd, | |
5121 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5122 | "Configure BGP aggregate entries\n" | |
5123 | "Aggregate prefix\n" | |
5124 | "Filter more specific routes from updates\n" | |
5125 | "Generate AS set path information\n") | |
5126 | ||
5127 | DEFUN (aggregate_address_mask_as_set_summary, | |
5128 | aggregate_address_mask_as_set_summary_cmd, | |
5129 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5130 | "Configure BGP aggregate entries\n" | |
5131 | "Aggregate address\n" | |
5132 | "Aggregate mask\n" | |
5133 | "Generate AS set path information\n" | |
5134 | "Filter more specific routes from updates\n") | |
5135 | { | |
5136 | int ret; | |
5137 | char prefix_str[BUFSIZ]; | |
5138 | ||
5139 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5140 | ||
5141 | if (! ret) | |
5142 | { | |
5143 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5144 | return CMD_WARNING; | |
5145 | } | |
5146 | ||
5147 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5148 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5149 | } | |
5150 | ||
5151 | ALIAS (aggregate_address_mask_as_set_summary, | |
5152 | aggregate_address_mask_summary_as_set_cmd, | |
5153 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5154 | "Configure BGP aggregate entries\n" | |
5155 | "Aggregate address\n" | |
5156 | "Aggregate mask\n" | |
5157 | "Filter more specific routes from updates\n" | |
5158 | "Generate AS set path information\n") | |
5159 | ||
5160 | DEFUN (no_aggregate_address, | |
5161 | no_aggregate_address_cmd, | |
5162 | "no aggregate-address A.B.C.D/M", | |
5163 | NO_STR | |
5164 | "Configure BGP aggregate entries\n" | |
5165 | "Aggregate prefix\n") | |
5166 | { | |
5167 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5168 | } | |
5169 | ||
5170 | ALIAS (no_aggregate_address, | |
5171 | no_aggregate_address_summary_only_cmd, | |
5172 | "no aggregate-address A.B.C.D/M summary-only", | |
5173 | NO_STR | |
5174 | "Configure BGP aggregate entries\n" | |
5175 | "Aggregate prefix\n" | |
5176 | "Filter more specific routes from updates\n") | |
5177 | ||
5178 | ALIAS (no_aggregate_address, | |
5179 | no_aggregate_address_as_set_cmd, | |
5180 | "no aggregate-address A.B.C.D/M as-set", | |
5181 | NO_STR | |
5182 | "Configure BGP aggregate entries\n" | |
5183 | "Aggregate prefix\n" | |
5184 | "Generate AS set path information\n") | |
5185 | ||
5186 | ALIAS (no_aggregate_address, | |
5187 | no_aggregate_address_as_set_summary_cmd, | |
5188 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5189 | NO_STR | |
5190 | "Configure BGP aggregate entries\n" | |
5191 | "Aggregate prefix\n" | |
5192 | "Generate AS set path information\n" | |
5193 | "Filter more specific routes from updates\n") | |
5194 | ||
5195 | ALIAS (no_aggregate_address, | |
5196 | no_aggregate_address_summary_as_set_cmd, | |
5197 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5198 | NO_STR | |
5199 | "Configure BGP aggregate entries\n" | |
5200 | "Aggregate prefix\n" | |
5201 | "Filter more specific routes from updates\n" | |
5202 | "Generate AS set path information\n") | |
5203 | ||
5204 | DEFUN (no_aggregate_address_mask, | |
5205 | no_aggregate_address_mask_cmd, | |
5206 | "no aggregate-address A.B.C.D A.B.C.D", | |
5207 | NO_STR | |
5208 | "Configure BGP aggregate entries\n" | |
5209 | "Aggregate address\n" | |
5210 | "Aggregate mask\n") | |
5211 | { | |
5212 | int ret; | |
5213 | char prefix_str[BUFSIZ]; | |
5214 | ||
5215 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5216 | ||
5217 | if (! ret) | |
5218 | { | |
5219 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5220 | return CMD_WARNING; | |
5221 | } | |
5222 | ||
5223 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5224 | } | |
5225 | ||
5226 | ALIAS (no_aggregate_address_mask, | |
5227 | no_aggregate_address_mask_summary_only_cmd, | |
5228 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5229 | NO_STR | |
5230 | "Configure BGP aggregate entries\n" | |
5231 | "Aggregate address\n" | |
5232 | "Aggregate mask\n" | |
5233 | "Filter more specific routes from updates\n") | |
5234 | ||
5235 | ALIAS (no_aggregate_address_mask, | |
5236 | no_aggregate_address_mask_as_set_cmd, | |
5237 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5238 | NO_STR | |
5239 | "Configure BGP aggregate entries\n" | |
5240 | "Aggregate address\n" | |
5241 | "Aggregate mask\n" | |
5242 | "Generate AS set path information\n") | |
5243 | ||
5244 | ALIAS (no_aggregate_address_mask, | |
5245 | no_aggregate_address_mask_as_set_summary_cmd, | |
5246 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5247 | NO_STR | |
5248 | "Configure BGP aggregate entries\n" | |
5249 | "Aggregate address\n" | |
5250 | "Aggregate mask\n" | |
5251 | "Generate AS set path information\n" | |
5252 | "Filter more specific routes from updates\n") | |
5253 | ||
5254 | ALIAS (no_aggregate_address_mask, | |
5255 | no_aggregate_address_mask_summary_as_set_cmd, | |
5256 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5257 | NO_STR | |
5258 | "Configure BGP aggregate entries\n" | |
5259 | "Aggregate address\n" | |
5260 | "Aggregate mask\n" | |
5261 | "Filter more specific routes from updates\n" | |
5262 | "Generate AS set path information\n") | |
5263 | ||
5264 | #ifdef HAVE_IPV6 | |
5265 | DEFUN (ipv6_aggregate_address, | |
5266 | ipv6_aggregate_address_cmd, | |
5267 | "aggregate-address X:X::X:X/M", | |
5268 | "Configure BGP aggregate entries\n" | |
5269 | "Aggregate prefix\n") | |
5270 | { | |
5271 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5272 | } | |
5273 | ||
5274 | DEFUN (ipv6_aggregate_address_summary_only, | |
5275 | ipv6_aggregate_address_summary_only_cmd, | |
5276 | "aggregate-address X:X::X:X/M summary-only", | |
5277 | "Configure BGP aggregate entries\n" | |
5278 | "Aggregate prefix\n" | |
5279 | "Filter more specific routes from updates\n") | |
5280 | { | |
5281 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5282 | AGGREGATE_SUMMARY_ONLY, 0); | |
5283 | } | |
5284 | ||
5285 | DEFUN (no_ipv6_aggregate_address, | |
5286 | no_ipv6_aggregate_address_cmd, | |
5287 | "no aggregate-address X:X::X:X/M", | |
5288 | NO_STR | |
5289 | "Configure BGP aggregate entries\n" | |
5290 | "Aggregate prefix\n") | |
5291 | { | |
5292 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5293 | } | |
5294 | ||
5295 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5296 | no_ipv6_aggregate_address_summary_only_cmd, | |
5297 | "no aggregate-address X:X::X:X/M summary-only", | |
5298 | NO_STR | |
5299 | "Configure BGP aggregate entries\n" | |
5300 | "Aggregate prefix\n" | |
5301 | "Filter more specific routes from updates\n") | |
5302 | { | |
5303 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5304 | } | |
5305 | ||
5306 | ALIAS (ipv6_aggregate_address, | |
5307 | old_ipv6_aggregate_address_cmd, | |
5308 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5309 | IPV6_STR | |
5310 | BGP_STR | |
5311 | "Configure BGP aggregate entries\n" | |
5312 | "Aggregate prefix\n") | |
5313 | ||
5314 | ALIAS (ipv6_aggregate_address_summary_only, | |
5315 | old_ipv6_aggregate_address_summary_only_cmd, | |
5316 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5317 | IPV6_STR | |
5318 | BGP_STR | |
5319 | "Configure BGP aggregate entries\n" | |
5320 | "Aggregate prefix\n" | |
5321 | "Filter more specific routes from updates\n") | |
5322 | ||
5323 | ALIAS (no_ipv6_aggregate_address, | |
5324 | old_no_ipv6_aggregate_address_cmd, | |
5325 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5326 | NO_STR | |
5327 | IPV6_STR | |
5328 | BGP_STR | |
5329 | "Configure BGP aggregate entries\n" | |
5330 | "Aggregate prefix\n") | |
5331 | ||
5332 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5333 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5334 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5335 | NO_STR | |
5336 | IPV6_STR | |
5337 | BGP_STR | |
5338 | "Configure BGP aggregate entries\n" | |
5339 | "Aggregate prefix\n" | |
5340 | "Filter more specific routes from updates\n") | |
5341 | #endif /* HAVE_IPV6 */ | |
5342 | \f | |
5343 | /* Redistribute route treatment. */ | |
5344 | void | |
f04a80a5 SH |
5345 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
5346 | const struct in6_addr *nexthop6, | |
718e3744 | 5347 | u_int32_t metric, u_char type) |
5348 | { | |
5349 | struct bgp *bgp; | |
1eb8ef25 | 5350 | struct listnode *node, *nnode; |
718e3744 | 5351 | struct bgp_info *new; |
5352 | struct bgp_info *bi; | |
5353 | struct bgp_info info; | |
5354 | struct bgp_node *bn; | |
fb982c25 PJ |
5355 | struct attr attr = { 0 }; |
5356 | struct attr attr_new = { 0 }; | |
718e3744 | 5357 | struct attr *new_attr; |
5358 | afi_t afi; | |
5359 | int ret; | |
5360 | ||
5361 | /* Make default attribute. */ | |
5362 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5363 | if (nexthop) | |
5364 | attr.nexthop = *nexthop; | |
5365 | ||
f04a80a5 SH |
5366 | #ifdef HAVE_IPV6 |
5367 | if (nexthop6) | |
5368 | { | |
5369 | struct attr_extra *extra = bgp_attr_extra_get(&attr); | |
5370 | extra->mp_nexthop_global = *nexthop6; | |
5371 | extra->mp_nexthop_len = 16; | |
5372 | } | |
5373 | #endif | |
5374 | ||
718e3744 | 5375 | attr.med = metric; |
5376 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
5377 | ||
1eb8ef25 | 5378 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5379 | { |
5380 | afi = family2afi (p->family); | |
5381 | ||
5382 | if (bgp->redist[afi][type]) | |
5383 | { | |
5384 | /* Copy attribute for modification. */ | |
fb982c25 | 5385 | bgp_attr_dup (&attr_new, &attr); |
718e3744 | 5386 | |
5387 | if (bgp->redist_metric_flag[afi][type]) | |
5388 | attr_new.med = bgp->redist_metric[afi][type]; | |
5389 | ||
5390 | /* Apply route-map. */ | |
5391 | if (bgp->rmap[afi][type].map) | |
5392 | { | |
5393 | info.peer = bgp->peer_self; | |
5394 | info.attr = &attr_new; | |
5395 | ||
fee0f4c6 | 5396 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
5397 | ||
718e3744 | 5398 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
5399 | &info); | |
fee0f4c6 | 5400 | |
5401 | bgp->peer_self->rmap_type = 0; | |
5402 | ||
718e3744 | 5403 | if (ret == RMAP_DENYMATCH) |
5404 | { | |
5405 | /* Free uninterned attribute. */ | |
5406 | bgp_attr_flush (&attr_new); | |
fb982c25 PJ |
5407 | bgp_attr_extra_free (&attr_new); |
5408 | ||
718e3744 | 5409 | /* Unintern original. */ |
f6f434b2 | 5410 | aspath_unintern (&attr.aspath); |
fb982c25 | 5411 | bgp_attr_extra_free (&attr); |
718e3744 | 5412 | bgp_redistribute_delete (p, type); |
5413 | return; | |
5414 | } | |
5415 | } | |
5416 | ||
fb982c25 PJ |
5417 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5418 | afi, SAFI_UNICAST, p, NULL); | |
5419 | ||
718e3744 | 5420 | new_attr = bgp_attr_intern (&attr_new); |
fb982c25 PJ |
5421 | bgp_attr_extra_free (&attr_new); |
5422 | ||
718e3744 | 5423 | for (bi = bn->info; bi; bi = bi->next) |
5424 | if (bi->peer == bgp->peer_self | |
5425 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5426 | break; | |
5427 | ||
5428 | if (bi) | |
5429 | { | |
8d45210e AS |
5430 | if (attrhash_cmp (bi->attr, new_attr) && |
5431 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
718e3744 | 5432 | { |
f6f434b2 PJ |
5433 | bgp_attr_unintern (&new_attr); |
5434 | aspath_unintern (&attr.aspath); | |
fb982c25 | 5435 | bgp_attr_extra_free (&attr); |
718e3744 | 5436 | bgp_unlock_node (bn); |
5437 | return; | |
5438 | } | |
5439 | else | |
5440 | { | |
5441 | /* The attribute is changed. */ | |
1a392d46 | 5442 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
718e3744 | 5443 | |
5444 | /* Rewrite BGP route information. */ | |
8d45210e AS |
5445 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
5446 | bgp_info_restore(bn, bi); | |
5447 | else | |
5448 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
f6f434b2 | 5449 | bgp_attr_unintern (&bi->attr); |
718e3744 | 5450 | bi->attr = new_attr; |
65957886 | 5451 | bi->uptime = bgp_clock (); |
718e3744 | 5452 | |
5453 | /* Process change. */ | |
5454 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5455 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5456 | bgp_unlock_node (bn); | |
f6f434b2 | 5457 | aspath_unintern (&attr.aspath); |
fb982c25 | 5458 | bgp_attr_extra_free (&attr); |
718e3744 | 5459 | return; |
5460 | } | |
5461 | } | |
5462 | ||
5463 | new = bgp_info_new (); | |
5464 | new->type = type; | |
5465 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; | |
5466 | new->peer = bgp->peer_self; | |
5467 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5468 | new->attr = new_attr; | |
65957886 | 5469 | new->uptime = bgp_clock (); |
718e3744 | 5470 | |
5471 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5472 | bgp_info_add (bn, new); | |
200df115 | 5473 | bgp_unlock_node (bn); |
718e3744 | 5474 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
5475 | } | |
5476 | } | |
5477 | ||
5478 | /* Unintern original. */ | |
f6f434b2 | 5479 | aspath_unintern (&attr.aspath); |
fb982c25 | 5480 | bgp_attr_extra_free (&attr); |
718e3744 | 5481 | } |
5482 | ||
5483 | void | |
5484 | bgp_redistribute_delete (struct prefix *p, u_char type) | |
5485 | { | |
5486 | struct bgp *bgp; | |
1eb8ef25 | 5487 | struct listnode *node, *nnode; |
718e3744 | 5488 | afi_t afi; |
5489 | struct bgp_node *rn; | |
5490 | struct bgp_info *ri; | |
5491 | ||
1eb8ef25 | 5492 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5493 | { |
5494 | afi = family2afi (p->family); | |
5495 | ||
5496 | if (bgp->redist[afi][type]) | |
5497 | { | |
fee0f4c6 | 5498 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
718e3744 | 5499 | |
5500 | for (ri = rn->info; ri; ri = ri->next) | |
5501 | if (ri->peer == bgp->peer_self | |
5502 | && ri->type == type) | |
5503 | break; | |
5504 | ||
5505 | if (ri) | |
5506 | { | |
5507 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5508 | bgp_info_delete (rn, ri); |
1a392d46 | 5509 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5510 | } |
5511 | bgp_unlock_node (rn); | |
5512 | } | |
5513 | } | |
5514 | } | |
5515 | ||
5516 | /* Withdraw specified route type's route. */ | |
5517 | void | |
5518 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) | |
5519 | { | |
5520 | struct bgp_node *rn; | |
5521 | struct bgp_info *ri; | |
5522 | struct bgp_table *table; | |
5523 | ||
5524 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5525 | ||
5526 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5527 | { | |
5528 | for (ri = rn->info; ri; ri = ri->next) | |
5529 | if (ri->peer == bgp->peer_self | |
5530 | && ri->type == type) | |
5531 | break; | |
5532 | ||
5533 | if (ri) | |
5534 | { | |
5535 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5536 | bgp_info_delete (rn, ri); |
1a392d46 | 5537 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5538 | } |
5539 | } | |
5540 | } | |
5541 | \f | |
5542 | /* Static function to display route. */ | |
94f2b392 | 5543 | static void |
718e3744 | 5544 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5545 | { | |
5546 | int len; | |
5547 | u_int32_t destination; | |
5548 | char buf[BUFSIZ]; | |
5549 | ||
5550 | if (p->family == AF_INET) | |
5551 | { | |
5552 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5553 | destination = ntohl (p->u.prefix4.s_addr); | |
5554 | ||
5555 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
5556 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
5557 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5558 | || p->u.prefix4.s_addr == 0) | |
5559 | { | |
5560 | /* When mask is natural, mask is not displayed. */ | |
5561 | } | |
5562 | else | |
5563 | len += vty_out (vty, "/%d", p->prefixlen); | |
5564 | } | |
5565 | else | |
5566 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5567 | p->prefixlen); | |
5568 | ||
5569 | len = 17 - len; | |
5570 | if (len < 1) | |
5571 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5572 | else | |
5573 | vty_out (vty, "%*s", len, " "); | |
5574 | } | |
5575 | ||
718e3744 | 5576 | enum bgp_display_type |
5577 | { | |
5578 | normal_list, | |
5579 | }; | |
5580 | ||
b40d939b | 5581 | /* Print the short form route status for a bgp_info */ |
5582 | static void | |
5583 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) | |
718e3744 | 5584 | { |
b40d939b | 5585 | /* Route status display. */ |
5586 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5587 | vty_out (vty, "R"); | |
5588 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5589 | vty_out (vty, "S"); |
fb982c25 | 5590 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5591 | vty_out (vty, "s"); |
5592 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5593 | vty_out (vty, "*"); | |
5594 | else | |
5595 | vty_out (vty, " "); | |
5596 | ||
5597 | /* Selected */ | |
5598 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5599 | vty_out (vty, "h"); | |
5600 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5601 | vty_out (vty, "d"); | |
5602 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5603 | vty_out (vty, ">"); | |
5604 | else | |
5605 | vty_out (vty, " "); | |
5606 | ||
5607 | /* Internal route. */ | |
5608 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
5609 | vty_out (vty, "i"); | |
5610 | else | |
b40d939b | 5611 | vty_out (vty, " "); |
5612 | } | |
5613 | ||
5614 | /* called from terminal list command */ | |
5615 | void | |
5616 | route_vty_out (struct vty *vty, struct prefix *p, | |
5617 | struct bgp_info *binfo, int display, safi_t safi) | |
5618 | { | |
5619 | struct attr *attr; | |
5620 | ||
5621 | /* short status lead text */ | |
5622 | route_vty_short_status_out (vty, binfo); | |
718e3744 | 5623 | |
5624 | /* print prefix and mask */ | |
5625 | if (! display) | |
5626 | route_vty_out_route (p, vty); | |
5627 | else | |
5628 | vty_out (vty, "%*s", 17, " "); | |
5629 | ||
5630 | /* Print attribute */ | |
5631 | attr = binfo->attr; | |
5632 | if (attr) | |
5633 | { | |
5634 | if (p->family == AF_INET) | |
5635 | { | |
5636 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5637 | vty_out (vty, "%-16s", |
5638 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5639 | else |
5640 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5641 | } | |
5642 | #ifdef HAVE_IPV6 | |
5643 | else if (p->family == AF_INET6) | |
5644 | { | |
5645 | int len; | |
5646 | char buf[BUFSIZ]; | |
5647 | ||
5648 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5649 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5650 | buf, BUFSIZ)); | |
718e3744 | 5651 | len = 16 - len; |
5652 | if (len < 1) | |
5653 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5654 | else | |
5655 | vty_out (vty, "%*s", len, " "); | |
5656 | } | |
5657 | #endif /* HAVE_IPV6 */ | |
5658 | ||
5659 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5660 | vty_out (vty, "%10u", attr->med); |
718e3744 | 5661 | else |
5662 | vty_out (vty, " "); | |
5663 | ||
5664 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5665 | vty_out (vty, "%7u", attr->local_pref); |
718e3744 | 5666 | else |
5667 | vty_out (vty, " "); | |
5668 | ||
fb982c25 | 5669 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 5670 | |
b2518c1e PJ |
5671 | /* Print aspath */ |
5672 | if (attr->aspath) | |
841f7a57 | 5673 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5674 | |
b2518c1e | 5675 | /* Print origin */ |
718e3744 | 5676 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5677 | } |
718e3744 | 5678 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5679 | } |
5680 | ||
5681 | /* called from terminal list command */ | |
5682 | void | |
5683 | route_vty_out_tmp (struct vty *vty, struct prefix *p, | |
5684 | struct attr *attr, safi_t safi) | |
5685 | { | |
5686 | /* Route status display. */ | |
5687 | vty_out (vty, "*"); | |
5688 | vty_out (vty, ">"); | |
5689 | vty_out (vty, " "); | |
5690 | ||
5691 | /* print prefix and mask */ | |
5692 | route_vty_out_route (p, vty); | |
5693 | ||
5694 | /* Print attribute */ | |
5695 | if (attr) | |
5696 | { | |
5697 | if (p->family == AF_INET) | |
5698 | { | |
5699 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5700 | vty_out (vty, "%-16s", |
5701 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5702 | else |
5703 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5704 | } | |
5705 | #ifdef HAVE_IPV6 | |
5706 | else if (p->family == AF_INET6) | |
5707 | { | |
5708 | int len; | |
5709 | char buf[BUFSIZ]; | |
fb982c25 PJ |
5710 | |
5711 | assert (attr->extra); | |
718e3744 | 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)) | |
c099baf6 | 5725 | vty_out (vty, "%10u", attr->med); |
718e3744 | 5726 | else |
5727 | vty_out (vty, " "); | |
5728 | ||
5729 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5730 | vty_out (vty, "%7u", attr->local_pref); |
718e3744 | 5731 | else |
5732 | vty_out (vty, " "); | |
fb982c25 | 5733 | |
c099baf6 | 5734 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
fb982c25 | 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 | |
5744 | vty_out (vty, "%s", VTY_NEWLINE); | |
5745 | } | |
5746 | ||
5a646650 | 5747 | void |
718e3744 | 5748 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
5749 | struct bgp_info *binfo, int display, safi_t safi) | |
5750 | { | |
5751 | struct attr *attr; | |
718e3744 | 5752 | u_int32_t label = 0; |
fb982c25 PJ |
5753 | |
5754 | if (!binfo->extra) | |
5755 | return; | |
5756 | ||
b40d939b | 5757 | /* short status lead text */ |
5758 | route_vty_short_status_out (vty, binfo); | |
5759 | ||
718e3744 | 5760 | /* print prefix and mask */ |
5761 | if (! display) | |
5762 | route_vty_out_route (p, vty); | |
5763 | else | |
5764 | vty_out (vty, "%*s", 17, " "); | |
5765 | ||
5766 | /* Print attribute */ | |
5767 | attr = binfo->attr; | |
5768 | if (attr) | |
5769 | { | |
5770 | if (p->family == AF_INET) | |
5771 | { | |
5772 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5773 | vty_out (vty, "%-16s", |
5774 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5775 | else |
5776 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5777 | } | |
5778 | #ifdef HAVE_IPV6 | |
5779 | else if (p->family == AF_INET6) | |
5780 | { | |
fb982c25 | 5781 | assert (attr->extra); |
718e3744 | 5782 | char buf[BUFSIZ]; |
5783 | char buf1[BUFSIZ]; | |
fb982c25 | 5784 | if (attr->extra->mp_nexthop_len == 16) |
718e3744 | 5785 | vty_out (vty, "%s", |
fb982c25 PJ |
5786 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5787 | buf, BUFSIZ)); | |
5788 | else if (attr->extra->mp_nexthop_len == 32) | |
718e3744 | 5789 | vty_out (vty, "%s(%s)", |
fb982c25 PJ |
5790 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5791 | buf, BUFSIZ), | |
5792 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
5793 | buf1, BUFSIZ)); | |
718e3744 | 5794 | |
5795 | } | |
5796 | #endif /* HAVE_IPV6 */ | |
5797 | } | |
5798 | ||
fb982c25 | 5799 | label = decode_label (binfo->extra->tag); |
718e3744 | 5800 | |
5801 | vty_out (vty, "notag/%d", label); | |
5802 | ||
5803 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5804 | } |
5805 | ||
5806 | /* dampening route */ | |
5a646650 | 5807 | static void |
718e3744 | 5808 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
5809 | struct bgp_info *binfo, int display, safi_t safi) | |
5810 | { | |
5811 | struct attr *attr; | |
718e3744 | 5812 | int len; |
50aef6f3 | 5813 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 5814 | |
b40d939b | 5815 | /* short status lead text */ |
5816 | route_vty_short_status_out (vty, binfo); | |
5817 | ||
718e3744 | 5818 | /* print prefix and mask */ |
5819 | if (! display) | |
5820 | route_vty_out_route (p, vty); | |
5821 | else | |
5822 | vty_out (vty, "%*s", 17, " "); | |
5823 | ||
5824 | len = vty_out (vty, "%s", binfo->peer->host); | |
5825 | len = 17 - len; | |
5826 | if (len < 1) | |
5827 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
5828 | else | |
5829 | vty_out (vty, "%*s", len, " "); | |
5830 | ||
50aef6f3 | 5831 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5832 | |
5833 | /* Print attribute */ | |
5834 | attr = binfo->attr; | |
5835 | if (attr) | |
5836 | { | |
5837 | /* Print aspath */ | |
5838 | if (attr->aspath) | |
841f7a57 | 5839 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5840 | |
5841 | /* Print origin */ | |
b2518c1e | 5842 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5843 | } |
5844 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5845 | } |
5846 | ||
718e3744 | 5847 | /* flap route */ |
5a646650 | 5848 | static void |
718e3744 | 5849 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
5850 | struct bgp_info *binfo, int display, safi_t safi) | |
5851 | { | |
5852 | struct attr *attr; | |
5853 | struct bgp_damp_info *bdi; | |
718e3744 | 5854 | char timebuf[BGP_UPTIME_LEN]; |
5855 | int len; | |
fb982c25 PJ |
5856 | |
5857 | if (!binfo->extra) | |
5858 | return; | |
5859 | ||
5860 | bdi = binfo->extra->damp_info; | |
718e3744 | 5861 | |
b40d939b | 5862 | /* short status lead text */ |
5863 | route_vty_short_status_out (vty, binfo); | |
5864 | ||
718e3744 | 5865 | /* print prefix and mask */ |
5866 | if (! display) | |
5867 | route_vty_out_route (p, vty); | |
5868 | else | |
5869 | vty_out (vty, "%*s", 17, " "); | |
5870 | ||
5871 | len = vty_out (vty, "%s", binfo->peer->host); | |
5872 | len = 16 - len; | |
5873 | if (len < 1) | |
5874 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
5875 | else | |
5876 | vty_out (vty, "%*s", len, " "); | |
5877 | ||
5878 | len = vty_out (vty, "%d", bdi->flap); | |
5879 | len = 5 - len; | |
5880 | if (len < 1) | |
5881 | vty_out (vty, " "); | |
5882 | else | |
5883 | vty_out (vty, "%*s ", len, " "); | |
5884 | ||
5885 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
5886 | timebuf, BGP_UPTIME_LEN)); | |
5887 | ||
5888 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
5889 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
50aef6f3 | 5890 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5891 | else |
5892 | vty_out (vty, "%*s ", 8, " "); | |
5893 | ||
5894 | /* Print attribute */ | |
5895 | attr = binfo->attr; | |
5896 | if (attr) | |
5897 | { | |
5898 | /* Print aspath */ | |
5899 | if (attr->aspath) | |
841f7a57 | 5900 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5901 | |
5902 | /* Print origin */ | |
b2518c1e | 5903 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5904 | } |
5905 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5906 | } |
5907 | ||
94f2b392 | 5908 | static void |
718e3744 | 5909 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
5910 | struct bgp_info *binfo, afi_t afi, safi_t safi) | |
5911 | { | |
5912 | char buf[INET6_ADDRSTRLEN]; | |
5913 | char buf1[BUFSIZ]; | |
5914 | struct attr *attr; | |
5915 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
5916 | #ifdef HAVE_CLOCK_MONOTONIC |
5917 | time_t tbuf; | |
5918 | #endif | |
718e3744 | 5919 | |
5920 | attr = binfo->attr; | |
5921 | ||
5922 | if (attr) | |
5923 | { | |
5924 | /* Line1 display AS-path, Aggregator */ | |
5925 | if (attr->aspath) | |
5926 | { | |
5927 | vty_out (vty, " "); | |
fe69a505 | 5928 | if (aspath_count_hops (attr->aspath) == 0) |
718e3744 | 5929 | vty_out (vty, "Local"); |
5930 | else | |
841f7a57 | 5931 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
718e3744 | 5932 | } |
5933 | ||
b40d939b | 5934 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
5935 | vty_out (vty, ", (removed)"); | |
93406d87 | 5936 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
5937 | vty_out (vty, ", (stale)"); | |
5938 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) | |
aea339f7 | 5939 | vty_out (vty, ", (aggregated by %u %s)", |
fb982c25 PJ |
5940 | attr->extra->aggregator_as, |
5941 | inet_ntoa (attr->extra->aggregator_addr)); | |
93406d87 | 5942 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
5943 | vty_out (vty, ", (Received from a RR-client)"); | |
5944 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
5945 | vty_out (vty, ", (Received from a RS-client)"); | |
5946 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5947 | vty_out (vty, ", (history entry)"); | |
5948 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5949 | vty_out (vty, ", (suppressed due to dampening)"); | |
718e3744 | 5950 | vty_out (vty, "%s", VTY_NEWLINE); |
5951 | ||
5952 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
5953 | if (p->family == AF_INET) | |
5954 | { | |
5955 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? | |
fb982c25 | 5956 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
718e3744 | 5957 | inet_ntoa (attr->nexthop)); |
5958 | } | |
5959 | #ifdef HAVE_IPV6 | |
5960 | else | |
5961 | { | |
fb982c25 | 5962 | assert (attr->extra); |
718e3744 | 5963 | vty_out (vty, " %s", |
fb982c25 | 5964 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
718e3744 | 5965 | buf, INET6_ADDRSTRLEN)); |
5966 | } | |
5967 | #endif /* HAVE_IPV6 */ | |
5968 | ||
5969 | if (binfo->peer == bgp->peer_self) | |
5970 | { | |
5971 | vty_out (vty, " from %s ", | |
5972 | p->family == AF_INET ? "0.0.0.0" : "::"); | |
5973 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); | |
5974 | } | |
5975 | else | |
5976 | { | |
5977 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
5978 | vty_out (vty, " (inaccessible)"); | |
fb982c25 | 5979 | else if (binfo->extra && binfo->extra->igpmetric) |
ddc943de | 5980 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
eb821189 | 5981 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
718e3744 | 5982 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 | 5983 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
718e3744 | 5984 | else |
5985 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
5986 | } | |
5987 | vty_out (vty, "%s", VTY_NEWLINE); | |
5988 | ||
5989 | #ifdef HAVE_IPV6 | |
5990 | /* display nexthop local */ | |
fb982c25 | 5991 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
718e3744 | 5992 | { |
5993 | vty_out (vty, " (%s)%s", | |
fb982c25 | 5994 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
718e3744 | 5995 | buf, INET6_ADDRSTRLEN), |
5996 | VTY_NEWLINE); | |
5997 | } | |
5998 | #endif /* HAVE_IPV6 */ | |
5999 | ||
6000 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ | |
6001 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); | |
6002 | ||
6003 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 6004 | vty_out (vty, ", metric %u", attr->med); |
718e3744 | 6005 | |
6006 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 6007 | vty_out (vty, ", localpref %u", attr->local_pref); |
718e3744 | 6008 | else |
c099baf6 | 6009 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
718e3744 | 6010 | |
fb982c25 | 6011 | if (attr->extra && attr->extra->weight != 0) |
c099baf6 | 6012 | vty_out (vty, ", weight %u", attr->extra->weight); |
718e3744 | 6013 | |
6014 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
6015 | vty_out (vty, ", valid"); | |
6016 | ||
6017 | if (binfo->peer != bgp->peer_self) | |
6018 | { | |
6019 | if (binfo->peer->as == binfo->peer->local_as) | |
6020 | vty_out (vty, ", internal"); | |
6021 | else | |
6022 | vty_out (vty, ", %s", | |
6023 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); | |
6024 | } | |
6025 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
6026 | vty_out (vty, ", aggregated, local"); | |
6027 | else if (binfo->type != ZEBRA_ROUTE_BGP) | |
6028 | vty_out (vty, ", sourced"); | |
6029 | else | |
6030 | vty_out (vty, ", sourced, local"); | |
6031 | ||
6032 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
6033 | vty_out (vty, ", atomic-aggregate"); | |
6034 | ||
de8d5dff JB |
6035 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
6036 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && | |
6037 | bgp_info_mpath_count (binfo))) | |
6038 | vty_out (vty, ", multipath"); | |
6039 | ||
718e3744 | 6040 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
6041 | vty_out (vty, ", best"); | |
6042 | ||
6043 | vty_out (vty, "%s", VTY_NEWLINE); | |
6044 | ||
6045 | /* Line 4 display Community */ | |
6046 | if (attr->community) | |
6047 | vty_out (vty, " Community: %s%s", attr->community->str, | |
6048 | VTY_NEWLINE); | |
6049 | ||
6050 | /* Line 5 display Extended-community */ | |
6051 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
fb982c25 PJ |
6052 | vty_out (vty, " Extended Community: %s%s", |
6053 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
718e3744 | 6054 | |
6055 | /* Line 6 display Originator, Cluster-id */ | |
6056 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
6057 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
6058 | { | |
fb982c25 | 6059 | assert (attr->extra); |
718e3744 | 6060 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 PJ |
6061 | vty_out (vty, " Originator: %s", |
6062 | inet_ntoa (attr->extra->originator_id)); | |
718e3744 | 6063 | |
6064 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
6065 | { | |
6066 | int i; | |
6067 | vty_out (vty, ", Cluster list: "); | |
fb982c25 PJ |
6068 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
6069 | vty_out (vty, "%s ", | |
6070 | inet_ntoa (attr->extra->cluster->list[i])); | |
718e3744 | 6071 | } |
6072 | vty_out (vty, "%s", VTY_NEWLINE); | |
6073 | } | |
41367172 | 6074 | |
fb982c25 | 6075 | if (binfo->extra && binfo->extra->damp_info) |
718e3744 | 6076 | bgp_damp_info_vty (vty, binfo); |
6077 | ||
6078 | /* Line 7 display Uptime */ | |
30b00176 JK |
6079 | #ifdef HAVE_CLOCK_MONOTONIC |
6080 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
213b6cd9 | 6081 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
30b00176 JK |
6082 | #else |
6083 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
6084 | #endif /* HAVE_CLOCK_MONOTONIC */ | |
718e3744 | 6085 | } |
6086 | vty_out (vty, "%s", VTY_NEWLINE); | |
6087 | } | |
6088 | \f | |
b40d939b | 6089 | #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 | 6090 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
718e3744 | 6091 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
6092 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" | |
6093 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
6094 | ||
6095 | enum bgp_show_type | |
6096 | { | |
6097 | bgp_show_type_normal, | |
6098 | bgp_show_type_regexp, | |
6099 | bgp_show_type_prefix_list, | |
6100 | bgp_show_type_filter_list, | |
6101 | bgp_show_type_route_map, | |
6102 | bgp_show_type_neighbor, | |
6103 | bgp_show_type_cidr_only, | |
6104 | bgp_show_type_prefix_longer, | |
6105 | bgp_show_type_community_all, | |
6106 | bgp_show_type_community, | |
6107 | bgp_show_type_community_exact, | |
6108 | bgp_show_type_community_list, | |
6109 | bgp_show_type_community_list_exact, | |
6110 | bgp_show_type_flap_statistics, | |
6111 | bgp_show_type_flap_address, | |
6112 | bgp_show_type_flap_prefix, | |
6113 | bgp_show_type_flap_cidr_only, | |
6114 | bgp_show_type_flap_regexp, | |
6115 | bgp_show_type_flap_filter_list, | |
6116 | bgp_show_type_flap_prefix_list, | |
6117 | bgp_show_type_flap_prefix_longer, | |
6118 | bgp_show_type_flap_route_map, | |
6119 | bgp_show_type_flap_neighbor, | |
6120 | bgp_show_type_dampend_paths, | |
6121 | bgp_show_type_damp_neighbor | |
6122 | }; | |
6123 | ||
5a646650 | 6124 | static int |
fee0f4c6 | 6125 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
5a646650 | 6126 | enum bgp_show_type type, void *output_arg) |
718e3744 | 6127 | { |
718e3744 | 6128 | struct bgp_info *ri; |
6129 | struct bgp_node *rn; | |
718e3744 | 6130 | int header = 1; |
718e3744 | 6131 | int display; |
5a646650 | 6132 | unsigned long output_count; |
718e3744 | 6133 | |
6134 | /* This is first entry point, so reset total line. */ | |
5a646650 | 6135 | output_count = 0; |
718e3744 | 6136 | |
718e3744 | 6137 | /* Start processing of routes. */ |
6138 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
6139 | if (rn->info != NULL) | |
6140 | { | |
6141 | display = 0; | |
6142 | ||
6143 | for (ri = rn->info; ri; ri = ri->next) | |
6144 | { | |
5a646650 | 6145 | if (type == bgp_show_type_flap_statistics |
718e3744 | 6146 | || type == bgp_show_type_flap_address |
6147 | || type == bgp_show_type_flap_prefix | |
6148 | || type == bgp_show_type_flap_cidr_only | |
6149 | || type == bgp_show_type_flap_regexp | |
6150 | || type == bgp_show_type_flap_filter_list | |
6151 | || type == bgp_show_type_flap_prefix_list | |
6152 | || type == bgp_show_type_flap_prefix_longer | |
6153 | || type == bgp_show_type_flap_route_map | |
6154 | || type == bgp_show_type_flap_neighbor | |
6155 | || type == bgp_show_type_dampend_paths | |
6156 | || type == bgp_show_type_damp_neighbor) | |
6157 | { | |
fb982c25 | 6158 | if (!(ri->extra && ri->extra->damp_info)) |
718e3744 | 6159 | continue; |
6160 | } | |
6161 | if (type == bgp_show_type_regexp | |
6162 | || type == bgp_show_type_flap_regexp) | |
6163 | { | |
5a646650 | 6164 | regex_t *regex = output_arg; |
718e3744 | 6165 | |
6166 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) | |
6167 | continue; | |
6168 | } | |
6169 | if (type == bgp_show_type_prefix_list | |
6170 | || type == bgp_show_type_flap_prefix_list) | |
6171 | { | |
5a646650 | 6172 | struct prefix_list *plist = output_arg; |
718e3744 | 6173 | |
6174 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) | |
6175 | continue; | |
6176 | } | |
6177 | if (type == bgp_show_type_filter_list | |
6178 | || type == bgp_show_type_flap_filter_list) | |
6179 | { | |
5a646650 | 6180 | struct as_list *as_list = output_arg; |
718e3744 | 6181 | |
6182 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) | |
6183 | continue; | |
6184 | } | |
6185 | if (type == bgp_show_type_route_map | |
6186 | || type == bgp_show_type_flap_route_map) | |
6187 | { | |
5a646650 | 6188 | struct route_map *rmap = output_arg; |
718e3744 | 6189 | struct bgp_info binfo; |
9eda90ce | 6190 | struct attr dummy_attr = { 0 }; |
718e3744 | 6191 | int ret; |
6192 | ||
fb982c25 | 6193 | bgp_attr_dup (&dummy_attr, ri->attr); |
718e3744 | 6194 | binfo.peer = ri->peer; |
6195 | binfo.attr = &dummy_attr; | |
6196 | ||
6197 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); | |
fb982c25 PJ |
6198 | |
6199 | bgp_attr_extra_free (&dummy_attr); | |
6200 | ||
718e3744 | 6201 | if (ret == RMAP_DENYMATCH) |
6202 | continue; | |
6203 | } | |
6204 | if (type == bgp_show_type_neighbor | |
6205 | || type == bgp_show_type_flap_neighbor | |
6206 | || type == bgp_show_type_damp_neighbor) | |
6207 | { | |
5a646650 | 6208 | union sockunion *su = output_arg; |
718e3744 | 6209 | |
6210 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) | |
6211 | continue; | |
6212 | } | |
6213 | if (type == bgp_show_type_cidr_only | |
6214 | || type == bgp_show_type_flap_cidr_only) | |
6215 | { | |
6216 | u_int32_t destination; | |
6217 | ||
6218 | destination = ntohl (rn->p.u.prefix4.s_addr); | |
6219 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
6220 | continue; | |
6221 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
6222 | continue; | |
6223 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
6224 | continue; | |
6225 | } | |
6226 | if (type == bgp_show_type_prefix_longer | |
6227 | || type == bgp_show_type_flap_prefix_longer) | |
6228 | { | |
5a646650 | 6229 | struct prefix *p = output_arg; |
718e3744 | 6230 | |
6231 | if (! prefix_match (p, &rn->p)) | |
6232 | continue; | |
6233 | } | |
6234 | if (type == bgp_show_type_community_all) | |
6235 | { | |
6236 | if (! ri->attr->community) | |
6237 | continue; | |
6238 | } | |
6239 | if (type == bgp_show_type_community) | |
6240 | { | |
5a646650 | 6241 | struct community *com = output_arg; |
718e3744 | 6242 | |
6243 | if (! ri->attr->community || | |
6244 | ! community_match (ri->attr->community, com)) | |
6245 | continue; | |
6246 | } | |
6247 | if (type == bgp_show_type_community_exact) | |
6248 | { | |
5a646650 | 6249 | struct community *com = output_arg; |
718e3744 | 6250 | |
6251 | if (! ri->attr->community || | |
6252 | ! community_cmp (ri->attr->community, com)) | |
6253 | continue; | |
6254 | } | |
6255 | if (type == bgp_show_type_community_list) | |
6256 | { | |
5a646650 | 6257 | struct community_list *list = output_arg; |
718e3744 | 6258 | |
6259 | if (! community_list_match (ri->attr->community, list)) | |
6260 | continue; | |
6261 | } | |
6262 | if (type == bgp_show_type_community_list_exact) | |
6263 | { | |
5a646650 | 6264 | struct community_list *list = output_arg; |
718e3744 | 6265 | |
6266 | if (! community_list_exact_match (ri->attr->community, list)) | |
6267 | continue; | |
6268 | } | |
6269 | if (type == bgp_show_type_flap_address | |
6270 | || type == bgp_show_type_flap_prefix) | |
6271 | { | |
5a646650 | 6272 | struct prefix *p = output_arg; |
718e3744 | 6273 | |
6274 | if (! prefix_match (&rn->p, p)) | |
6275 | continue; | |
6276 | ||
6277 | if (type == bgp_show_type_flap_prefix) | |
6278 | if (p->prefixlen != rn->p.prefixlen) | |
6279 | continue; | |
6280 | } | |
6281 | if (type == bgp_show_type_dampend_paths | |
6282 | || type == bgp_show_type_damp_neighbor) | |
6283 | { | |
6284 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
6285 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
6286 | continue; | |
6287 | } | |
6288 | ||
6289 | if (header) | |
6290 | { | |
93406d87 | 6291 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
6292 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
6293 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 6294 | if (type == bgp_show_type_dampend_paths |
6295 | || type == bgp_show_type_damp_neighbor) | |
6296 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
6297 | else if (type == bgp_show_type_flap_statistics | |
6298 | || type == bgp_show_type_flap_address | |
6299 | || type == bgp_show_type_flap_prefix | |
6300 | || type == bgp_show_type_flap_cidr_only | |
6301 | || type == bgp_show_type_flap_regexp | |
6302 | || type == bgp_show_type_flap_filter_list | |
6303 | || type == bgp_show_type_flap_prefix_list | |
6304 | || type == bgp_show_type_flap_prefix_longer | |
6305 | || type == bgp_show_type_flap_route_map | |
6306 | || type == bgp_show_type_flap_neighbor) | |
6307 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
6308 | else | |
6309 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
718e3744 | 6310 | header = 0; |
6311 | } | |
6312 | ||
6313 | if (type == bgp_show_type_dampend_paths | |
6314 | || type == bgp_show_type_damp_neighbor) | |
5a646650 | 6315 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6316 | else if (type == bgp_show_type_flap_statistics |
6317 | || type == bgp_show_type_flap_address | |
6318 | || type == bgp_show_type_flap_prefix | |
6319 | || type == bgp_show_type_flap_cidr_only | |
6320 | || type == bgp_show_type_flap_regexp | |
6321 | || type == bgp_show_type_flap_filter_list | |
6322 | || type == bgp_show_type_flap_prefix_list | |
6323 | || type == bgp_show_type_flap_prefix_longer | |
6324 | || type == bgp_show_type_flap_route_map | |
6325 | || type == bgp_show_type_flap_neighbor) | |
5a646650 | 6326 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6327 | else |
5a646650 | 6328 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6329 | display++; |
6330 | } | |
6331 | if (display) | |
5a646650 | 6332 | output_count++; |
718e3744 | 6333 | } |
6334 | ||
6335 | /* No route is displayed */ | |
5a646650 | 6336 | if (output_count == 0) |
718e3744 | 6337 | { |
6338 | if (type == bgp_show_type_normal) | |
6339 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); | |
6340 | } | |
6341 | else | |
6342 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
5a646650 | 6343 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
718e3744 | 6344 | |
6345 | return CMD_SUCCESS; | |
6346 | } | |
6347 | ||
5a646650 | 6348 | static int |
fee0f4c6 | 6349 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
5a646650 | 6350 | enum bgp_show_type type, void *output_arg) |
fee0f4c6 | 6351 | { |
6352 | struct bgp_table *table; | |
6353 | ||
6354 | if (bgp == NULL) { | |
6355 | bgp = bgp_get_default (); | |
6356 | } | |
6357 | ||
6358 | if (bgp == NULL) | |
6359 | { | |
6360 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6361 | return CMD_WARNING; | |
6362 | } | |
6363 | ||
6364 | ||
6365 | table = bgp->rib[afi][safi]; | |
6366 | ||
5a646650 | 6367 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
fee0f4c6 | 6368 | } |
6369 | ||
718e3744 | 6370 | /* Header of detailed BGP route information */ |
94f2b392 | 6371 | static void |
718e3744 | 6372 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
6373 | struct bgp_node *rn, | |
6374 | struct prefix_rd *prd, afi_t afi, safi_t safi) | |
6375 | { | |
6376 | struct bgp_info *ri; | |
6377 | struct prefix *p; | |
6378 | struct peer *peer; | |
1eb8ef25 | 6379 | struct listnode *node, *nnode; |
718e3744 | 6380 | char buf1[INET6_ADDRSTRLEN]; |
6381 | char buf2[INET6_ADDRSTRLEN]; | |
6382 | int count = 0; | |
6383 | int best = 0; | |
6384 | int suppress = 0; | |
6385 | int no_export = 0; | |
6386 | int no_advertise = 0; | |
6387 | int local_as = 0; | |
6388 | int first = 0; | |
6389 | ||
6390 | p = &rn->p; | |
6391 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
6392 | (safi == SAFI_MPLS_VPN ? | |
6393 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), | |
6394 | safi == SAFI_MPLS_VPN ? ":" : "", | |
6395 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
6396 | p->prefixlen, VTY_NEWLINE); | |
6397 | ||
6398 | for (ri = rn->info; ri; ri = ri->next) | |
6399 | { | |
6400 | count++; | |
6401 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
6402 | { | |
6403 | best = count; | |
fb982c25 | 6404 | if (ri->extra && ri->extra->suppress) |
718e3744 | 6405 | suppress = 1; |
6406 | if (ri->attr->community != NULL) | |
6407 | { | |
6408 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
6409 | no_advertise = 1; | |
6410 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
6411 | no_export = 1; | |
6412 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
6413 | local_as = 1; | |
6414 | } | |
6415 | } | |
6416 | } | |
6417 | ||
6418 | vty_out (vty, "Paths: (%d available", count); | |
6419 | if (best) | |
6420 | { | |
6421 | vty_out (vty, ", best #%d", best); | |
6422 | if (safi == SAFI_UNICAST) | |
6423 | vty_out (vty, ", table Default-IP-Routing-Table"); | |
6424 | } | |
6425 | else | |
6426 | vty_out (vty, ", no best path"); | |
6427 | if (no_advertise) | |
6428 | vty_out (vty, ", not advertised to any peer"); | |
6429 | else if (no_export) | |
6430 | vty_out (vty, ", not advertised to EBGP peer"); | |
6431 | else if (local_as) | |
6432 | vty_out (vty, ", not advertised outside local AS"); | |
6433 | if (suppress) | |
6434 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
6435 | vty_out (vty, ")%s", VTY_NEWLINE); | |
6436 | ||
6437 | /* advertised peer */ | |
1eb8ef25 | 6438 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6439 | { |
6440 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) | |
6441 | { | |
6442 | if (! first) | |
6443 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); | |
6444 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6445 | first = 1; | |
6446 | } | |
6447 | } | |
6448 | if (! first) | |
6449 | vty_out (vty, " Not advertised to any peer"); | |
6450 | vty_out (vty, "%s", VTY_NEWLINE); | |
6451 | } | |
6452 | ||
6453 | /* Display specified route of BGP table. */ | |
94f2b392 | 6454 | static int |
fee0f4c6 | 6455 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 6456 | struct bgp_table *rib, const char *ip_str, |
6457 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
6458 | int prefix_check) | |
718e3744 | 6459 | { |
6460 | int ret; | |
6461 | int header; | |
6462 | int display = 0; | |
6463 | struct prefix match; | |
6464 | struct bgp_node *rn; | |
6465 | struct bgp_node *rm; | |
6466 | struct bgp_info *ri; | |
718e3744 | 6467 | struct bgp_table *table; |
6468 | ||
718e3744 | 6469 | /* Check IP address argument. */ |
6470 | ret = str2prefix (ip_str, &match); | |
6471 | if (! ret) | |
6472 | { | |
6473 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
6474 | return CMD_WARNING; | |
6475 | } | |
6476 | ||
6477 | match.family = afi2family (afi); | |
6478 | ||
6479 | if (safi == SAFI_MPLS_VPN) | |
6480 | { | |
fee0f4c6 | 6481 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 6482 | { |
6483 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6484 | continue; | |
6485 | ||
6486 | if ((table = rn->info) != NULL) | |
6487 | { | |
6488 | header = 1; | |
6489 | ||
6490 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6491 | { | |
6492 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
6493 | { |
6494 | bgp_unlock_node (rm); | |
6495 | continue; | |
6496 | } | |
718e3744 | 6497 | |
6498 | for (ri = rm->info; ri; ri = ri->next) | |
6499 | { | |
6500 | if (header) | |
6501 | { | |
6502 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
6503 | AFI_IP, SAFI_MPLS_VPN); | |
6504 | ||
6505 | header = 0; | |
6506 | } | |
6507 | display++; | |
6508 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); | |
6509 | } | |
6c88b44d CC |
6510 | |
6511 | bgp_unlock_node (rm); | |
718e3744 | 6512 | } |
6513 | } | |
6514 | } | |
6515 | } | |
6516 | else | |
6517 | { | |
6518 | header = 1; | |
6519 | ||
fee0f4c6 | 6520 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 6521 | { |
6522 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
6523 | { | |
6524 | for (ri = rn->info; ri; ri = ri->next) | |
6525 | { | |
6526 | if (header) | |
6527 | { | |
6528 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); | |
6529 | header = 0; | |
6530 | } | |
6531 | display++; | |
6532 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); | |
6533 | } | |
6534 | } | |
6c88b44d CC |
6535 | |
6536 | bgp_unlock_node (rn); | |
718e3744 | 6537 | } |
6538 | } | |
6539 | ||
6540 | if (! display) | |
6541 | { | |
6542 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
6543 | return CMD_WARNING; | |
6544 | } | |
6545 | ||
6546 | return CMD_SUCCESS; | |
6547 | } | |
6548 | ||
fee0f4c6 | 6549 | /* Display specified route of Main RIB */ |
94f2b392 | 6550 | static int |
fd79ac91 | 6551 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 6552 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
6553 | int prefix_check) | |
6554 | { | |
6555 | struct bgp *bgp; | |
6556 | ||
6557 | /* BGP structure lookup. */ | |
6558 | if (view_name) | |
6559 | { | |
6560 | bgp = bgp_lookup_by_name (view_name); | |
6561 | if (bgp == NULL) | |
6562 | { | |
6563 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
6564 | return CMD_WARNING; | |
6565 | } | |
6566 | } | |
6567 | else | |
6568 | { | |
6569 | bgp = bgp_get_default (); | |
6570 | if (bgp == NULL) | |
6571 | { | |
6572 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6573 | return CMD_WARNING; | |
6574 | } | |
6575 | } | |
6576 | ||
6577 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
6578 | afi, safi, prd, prefix_check); | |
6579 | } | |
6580 | ||
718e3744 | 6581 | /* BGP route print out function. */ |
6582 | DEFUN (show_ip_bgp, | |
6583 | show_ip_bgp_cmd, | |
6584 | "show ip bgp", | |
6585 | SHOW_STR | |
6586 | IP_STR | |
6587 | BGP_STR) | |
6588 | { | |
5a646650 | 6589 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6590 | } |
6591 | ||
6592 | DEFUN (show_ip_bgp_ipv4, | |
6593 | show_ip_bgp_ipv4_cmd, | |
6594 | "show ip bgp ipv4 (unicast|multicast)", | |
6595 | SHOW_STR | |
6596 | IP_STR | |
6597 | BGP_STR | |
6598 | "Address family\n" | |
6599 | "Address Family modifier\n" | |
6600 | "Address Family modifier\n") | |
6601 | { | |
6602 | if (strncmp (argv[0], "m", 1) == 0) | |
5a646650 | 6603 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
6604 | NULL); | |
718e3744 | 6605 | |
5a646650 | 6606 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6607 | } |
6608 | ||
95cbbd2a ML |
6609 | ALIAS (show_ip_bgp_ipv4, |
6610 | show_bgp_ipv4_safi_cmd, | |
6611 | "show bgp ipv4 (unicast|multicast)", | |
6612 | SHOW_STR | |
6613 | BGP_STR | |
6614 | "Address family\n" | |
6615 | "Address Family modifier\n" | |
6616 | "Address Family modifier\n") | |
6617 | ||
718e3744 | 6618 | DEFUN (show_ip_bgp_route, |
6619 | show_ip_bgp_route_cmd, | |
6620 | "show ip bgp A.B.C.D", | |
6621 | SHOW_STR | |
6622 | IP_STR | |
6623 | BGP_STR | |
6624 | "Network in the BGP routing table to display\n") | |
6625 | { | |
6626 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6627 | } | |
6628 | ||
6629 | DEFUN (show_ip_bgp_ipv4_route, | |
6630 | show_ip_bgp_ipv4_route_cmd, | |
6631 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", | |
6632 | SHOW_STR | |
6633 | IP_STR | |
6634 | BGP_STR | |
6635 | "Address family\n" | |
6636 | "Address Family modifier\n" | |
6637 | "Address Family modifier\n" | |
6638 | "Network in the BGP routing table to display\n") | |
6639 | { | |
6640 | if (strncmp (argv[0], "m", 1) == 0) | |
6641 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); | |
6642 | ||
6643 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6644 | } | |
6645 | ||
95cbbd2a ML |
6646 | ALIAS (show_ip_bgp_ipv4_route, |
6647 | show_bgp_ipv4_safi_route_cmd, | |
6648 | "show bgp ipv4 (unicast|multicast) A.B.C.D", | |
6649 | SHOW_STR | |
6650 | BGP_STR | |
6651 | "Address family\n" | |
6652 | "Address Family modifier\n" | |
6653 | "Address Family modifier\n" | |
6654 | "Network in the BGP routing table to display\n") | |
6655 | ||
718e3744 | 6656 | DEFUN (show_ip_bgp_vpnv4_all_route, |
6657 | show_ip_bgp_vpnv4_all_route_cmd, | |
6658 | "show ip bgp vpnv4 all A.B.C.D", | |
6659 | SHOW_STR | |
6660 | IP_STR | |
6661 | BGP_STR | |
6662 | "Display VPNv4 NLRI specific information\n" | |
6663 | "Display information about all VPNv4 NLRIs\n" | |
6664 | "Network in the BGP routing table to display\n") | |
6665 | { | |
6666 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); | |
6667 | } | |
6668 | ||
6669 | DEFUN (show_ip_bgp_vpnv4_rd_route, | |
6670 | show_ip_bgp_vpnv4_rd_route_cmd, | |
6671 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", | |
6672 | SHOW_STR | |
6673 | IP_STR | |
6674 | BGP_STR | |
6675 | "Display VPNv4 NLRI specific information\n" | |
6676 | "Display information for a route distinguisher\n" | |
6677 | "VPN Route Distinguisher\n" | |
6678 | "Network in the BGP routing table to display\n") | |
6679 | { | |
6680 | int ret; | |
6681 | struct prefix_rd prd; | |
6682 | ||
6683 | ret = str2prefix_rd (argv[0], &prd); | |
6684 | if (! ret) | |
6685 | { | |
6686 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6687 | return CMD_WARNING; | |
6688 | } | |
6689 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); | |
6690 | } | |
6691 | ||
6692 | DEFUN (show_ip_bgp_prefix, | |
6693 | show_ip_bgp_prefix_cmd, | |
6694 | "show ip bgp A.B.C.D/M", | |
6695 | SHOW_STR | |
6696 | IP_STR | |
6697 | BGP_STR | |
6698 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6699 | { | |
6700 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6701 | } | |
6702 | ||
6703 | DEFUN (show_ip_bgp_ipv4_prefix, | |
6704 | show_ip_bgp_ipv4_prefix_cmd, | |
6705 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6706 | SHOW_STR | |
6707 | IP_STR | |
6708 | BGP_STR | |
6709 | "Address family\n" | |
6710 | "Address Family modifier\n" | |
6711 | "Address Family modifier\n" | |
6712 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6713 | { | |
6714 | if (strncmp (argv[0], "m", 1) == 0) | |
6715 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); | |
6716 | ||
6717 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6718 | } | |
6719 | ||
95cbbd2a ML |
6720 | ALIAS (show_ip_bgp_ipv4_prefix, |
6721 | show_bgp_ipv4_safi_prefix_cmd, | |
6722 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6723 | SHOW_STR | |
6724 | BGP_STR | |
6725 | "Address family\n" | |
6726 | "Address Family modifier\n" | |
6727 | "Address Family modifier\n" | |
6728 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6729 | ||
718e3744 | 6730 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
6731 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
6732 | "show ip bgp vpnv4 all A.B.C.D/M", | |
6733 | SHOW_STR | |
6734 | IP_STR | |
6735 | BGP_STR | |
6736 | "Display VPNv4 NLRI specific information\n" | |
6737 | "Display information about all VPNv4 NLRIs\n" | |
6738 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6739 | { | |
6740 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); | |
6741 | } | |
6742 | ||
6743 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
6744 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
6745 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", | |
6746 | SHOW_STR | |
6747 | IP_STR | |
6748 | BGP_STR | |
6749 | "Display VPNv4 NLRI specific information\n" | |
6750 | "Display information for a route distinguisher\n" | |
6751 | "VPN Route Distinguisher\n" | |
6752 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6753 | { | |
6754 | int ret; | |
6755 | struct prefix_rd prd; | |
6756 | ||
6757 | ret = str2prefix_rd (argv[0], &prd); | |
6758 | if (! ret) | |
6759 | { | |
6760 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6761 | return CMD_WARNING; | |
6762 | } | |
6763 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); | |
6764 | } | |
6765 | ||
6766 | DEFUN (show_ip_bgp_view, | |
6767 | show_ip_bgp_view_cmd, | |
6768 | "show ip bgp view WORD", | |
6769 | SHOW_STR | |
6770 | IP_STR | |
6771 | BGP_STR | |
6772 | "BGP view\n" | |
6773 | "BGP view name\n") | |
6774 | { | |
bb46e94f | 6775 | struct bgp *bgp; |
6776 | ||
6777 | /* BGP structure lookup. */ | |
6778 | bgp = bgp_lookup_by_name (argv[0]); | |
6779 | if (bgp == NULL) | |
6780 | { | |
6781 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6782 | return CMD_WARNING; | |
6783 | } | |
6784 | ||
5a646650 | 6785 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6786 | } |
6787 | ||
6788 | DEFUN (show_ip_bgp_view_route, | |
6789 | show_ip_bgp_view_route_cmd, | |
6790 | "show ip bgp view WORD A.B.C.D", | |
6791 | SHOW_STR | |
6792 | IP_STR | |
6793 | BGP_STR | |
6794 | "BGP view\n" | |
6795 | "BGP view name\n" | |
6796 | "Network in the BGP routing table to display\n") | |
6797 | { | |
6798 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6799 | } | |
6800 | ||
6801 | DEFUN (show_ip_bgp_view_prefix, | |
6802 | show_ip_bgp_view_prefix_cmd, | |
6803 | "show ip bgp view WORD A.B.C.D/M", | |
6804 | SHOW_STR | |
6805 | IP_STR | |
6806 | BGP_STR | |
6807 | "BGP view\n" | |
6808 | "BGP view name\n" | |
6809 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6810 | { | |
6811 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6812 | } | |
6813 | ||
6814 | #ifdef HAVE_IPV6 | |
6815 | DEFUN (show_bgp, | |
6816 | show_bgp_cmd, | |
6817 | "show bgp", | |
6818 | SHOW_STR | |
6819 | BGP_STR) | |
6820 | { | |
5a646650 | 6821 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6822 | NULL); | |
718e3744 | 6823 | } |
6824 | ||
6825 | ALIAS (show_bgp, | |
6826 | show_bgp_ipv6_cmd, | |
6827 | "show bgp ipv6", | |
6828 | SHOW_STR | |
6829 | BGP_STR | |
6830 | "Address family\n") | |
6831 | ||
95cbbd2a ML |
6832 | DEFUN (show_bgp_ipv6_safi, |
6833 | show_bgp_ipv6_safi_cmd, | |
6834 | "show bgp ipv6 (unicast|multicast)", | |
6835 | SHOW_STR | |
6836 | BGP_STR | |
6837 | "Address family\n" | |
6838 | "Address Family modifier\n" | |
6839 | "Address Family modifier\n") | |
6840 | { | |
6841 | if (strncmp (argv[0], "m", 1) == 0) | |
6842 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, | |
6843 | NULL); | |
6844 | ||
6845 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); | |
6846 | } | |
6847 | ||
718e3744 | 6848 | /* old command */ |
6849 | DEFUN (show_ipv6_bgp, | |
6850 | show_ipv6_bgp_cmd, | |
6851 | "show ipv6 bgp", | |
6852 | SHOW_STR | |
6853 | IP_STR | |
6854 | BGP_STR) | |
6855 | { | |
5a646650 | 6856 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6857 | NULL); | |
718e3744 | 6858 | } |
6859 | ||
6860 | DEFUN (show_bgp_route, | |
6861 | show_bgp_route_cmd, | |
6862 | "show bgp X:X::X:X", | |
6863 | SHOW_STR | |
6864 | BGP_STR | |
6865 | "Network in the BGP routing table to display\n") | |
6866 | { | |
6867 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6868 | } | |
6869 | ||
6870 | ALIAS (show_bgp_route, | |
6871 | show_bgp_ipv6_route_cmd, | |
6872 | "show bgp ipv6 X:X::X:X", | |
6873 | SHOW_STR | |
6874 | BGP_STR | |
6875 | "Address family\n" | |
6876 | "Network in the BGP routing table to display\n") | |
6877 | ||
95cbbd2a ML |
6878 | DEFUN (show_bgp_ipv6_safi_route, |
6879 | show_bgp_ipv6_safi_route_cmd, | |
6880 | "show bgp ipv6 (unicast|multicast) X:X::X:X", | |
6881 | SHOW_STR | |
6882 | BGP_STR | |
6883 | "Address family\n" | |
6884 | "Address Family modifier\n" | |
6885 | "Address Family modifier\n" | |
6886 | "Network in the BGP routing table to display\n") | |
6887 | { | |
6888 | if (strncmp (argv[0], "m", 1) == 0) | |
6889 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
6890 | ||
6891 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6892 | } | |
6893 | ||
718e3744 | 6894 | /* old command */ |
6895 | DEFUN (show_ipv6_bgp_route, | |
6896 | show_ipv6_bgp_route_cmd, | |
6897 | "show ipv6 bgp X:X::X:X", | |
6898 | SHOW_STR | |
6899 | IP_STR | |
6900 | BGP_STR | |
6901 | "Network in the BGP routing table to display\n") | |
6902 | { | |
6903 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6904 | } | |
6905 | ||
6906 | DEFUN (show_bgp_prefix, | |
6907 | show_bgp_prefix_cmd, | |
6908 | "show bgp X:X::X:X/M", | |
6909 | SHOW_STR | |
6910 | BGP_STR | |
6911 | "IPv6 prefix <network>/<length>\n") | |
6912 | { | |
6913 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6914 | } | |
6915 | ||
6916 | ALIAS (show_bgp_prefix, | |
6917 | show_bgp_ipv6_prefix_cmd, | |
6918 | "show bgp ipv6 X:X::X:X/M", | |
6919 | SHOW_STR | |
6920 | BGP_STR | |
6921 | "Address family\n" | |
6922 | "IPv6 prefix <network>/<length>\n") | |
6923 | ||
95cbbd2a ML |
6924 | DEFUN (show_bgp_ipv6_safi_prefix, |
6925 | show_bgp_ipv6_safi_prefix_cmd, | |
6926 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", | |
6927 | SHOW_STR | |
6928 | BGP_STR | |
6929 | "Address family\n" | |
6930 | "Address Family modifier\n" | |
6931 | "Address Family modifier\n" | |
6932 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6933 | { | |
6934 | if (strncmp (argv[0], "m", 1) == 0) | |
6935 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
6936 | ||
6937 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6938 | } | |
6939 | ||
718e3744 | 6940 | /* old command */ |
6941 | DEFUN (show_ipv6_bgp_prefix, | |
6942 | show_ipv6_bgp_prefix_cmd, | |
6943 | "show ipv6 bgp X:X::X:X/M", | |
6944 | SHOW_STR | |
6945 | IP_STR | |
6946 | BGP_STR | |
6947 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6948 | { | |
6949 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6950 | } | |
6951 | ||
bb46e94f | 6952 | DEFUN (show_bgp_view, |
6953 | show_bgp_view_cmd, | |
6954 | "show bgp view WORD", | |
6955 | SHOW_STR | |
6956 | BGP_STR | |
6957 | "BGP view\n" | |
6958 | "View name\n") | |
6959 | { | |
6960 | struct bgp *bgp; | |
6961 | ||
6962 | /* BGP structure lookup. */ | |
6963 | bgp = bgp_lookup_by_name (argv[0]); | |
6964 | if (bgp == NULL) | |
6965 | { | |
6966 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6967 | return CMD_WARNING; | |
6968 | } | |
6969 | ||
5a646650 | 6970 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
bb46e94f | 6971 | } |
6972 | ||
6973 | ALIAS (show_bgp_view, | |
6974 | show_bgp_view_ipv6_cmd, | |
6975 | "show bgp view WORD ipv6", | |
6976 | SHOW_STR | |
6977 | BGP_STR | |
6978 | "BGP view\n" | |
6979 | "View name\n" | |
6980 | "Address family\n") | |
6981 | ||
6982 | DEFUN (show_bgp_view_route, | |
6983 | show_bgp_view_route_cmd, | |
6984 | "show bgp view WORD X:X::X:X", | |
6985 | SHOW_STR | |
6986 | BGP_STR | |
6987 | "BGP view\n" | |
6988 | "View name\n" | |
6989 | "Network in the BGP routing table to display\n") | |
6990 | { | |
6991 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6992 | } | |
6993 | ||
6994 | ALIAS (show_bgp_view_route, | |
6995 | show_bgp_view_ipv6_route_cmd, | |
6996 | "show bgp view WORD ipv6 X:X::X:X", | |
6997 | SHOW_STR | |
6998 | BGP_STR | |
6999 | "BGP view\n" | |
7000 | "View name\n" | |
7001 | "Address family\n" | |
7002 | "Network in the BGP routing table to display\n") | |
7003 | ||
7004 | DEFUN (show_bgp_view_prefix, | |
7005 | show_bgp_view_prefix_cmd, | |
7006 | "show bgp view WORD X:X::X:X/M", | |
7007 | SHOW_STR | |
7008 | BGP_STR | |
7009 | "BGP view\n" | |
7010 | "View name\n" | |
7011 | "IPv6 prefix <network>/<length>\n") | |
7012 | { | |
7013 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
7014 | } | |
7015 | ||
7016 | ALIAS (show_bgp_view_prefix, | |
7017 | show_bgp_view_ipv6_prefix_cmd, | |
7018 | "show bgp view WORD ipv6 X:X::X:X/M", | |
7019 | SHOW_STR | |
7020 | BGP_STR | |
7021 | "BGP view\n" | |
7022 | "View name\n" | |
7023 | "Address family\n" | |
7024 | "IPv6 prefix <network>/<length>\n") | |
7025 | ||
718e3744 | 7026 | /* old command */ |
7027 | DEFUN (show_ipv6_mbgp, | |
7028 | show_ipv6_mbgp_cmd, | |
7029 | "show ipv6 mbgp", | |
7030 | SHOW_STR | |
7031 | IP_STR | |
7032 | MBGP_STR) | |
7033 | { | |
5a646650 | 7034 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
7035 | NULL); | |
718e3744 | 7036 | } |
7037 | ||
7038 | /* old command */ | |
7039 | DEFUN (show_ipv6_mbgp_route, | |
7040 | show_ipv6_mbgp_route_cmd, | |
7041 | "show ipv6 mbgp X:X::X:X", | |
7042 | SHOW_STR | |
7043 | IP_STR | |
7044 | MBGP_STR | |
7045 | "Network in the MBGP routing table to display\n") | |
7046 | { | |
7047 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
7048 | } | |
7049 | ||
7050 | /* old command */ | |
7051 | DEFUN (show_ipv6_mbgp_prefix, | |
7052 | show_ipv6_mbgp_prefix_cmd, | |
7053 | "show ipv6 mbgp X:X::X:X/M", | |
7054 | SHOW_STR | |
7055 | IP_STR | |
7056 | MBGP_STR | |
7057 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
7058 | { | |
7059 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
7060 | } | |
7061 | #endif | |
7062 | \f | |
718e3744 | 7063 | |
94f2b392 | 7064 | static int |
fd79ac91 | 7065 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 7066 | safi_t safi, enum bgp_show_type type) |
7067 | { | |
7068 | int i; | |
7069 | struct buffer *b; | |
7070 | char *regstr; | |
7071 | int first; | |
7072 | regex_t *regex; | |
5a646650 | 7073 | int rc; |
718e3744 | 7074 | |
7075 | first = 0; | |
7076 | b = buffer_new (1024); | |
7077 | for (i = 0; i < argc; i++) | |
7078 | { | |
7079 | if (first) | |
7080 | buffer_putc (b, ' '); | |
7081 | else | |
7082 | { | |
7083 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7084 | continue; | |
7085 | first = 1; | |
7086 | } | |
7087 | ||
7088 | buffer_putstr (b, argv[i]); | |
7089 | } | |
7090 | buffer_putc (b, '\0'); | |
7091 | ||
7092 | regstr = buffer_getstr (b); | |
7093 | buffer_free (b); | |
7094 | ||
7095 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 7096 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 7097 | if (! regex) |
7098 | { | |
7099 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
7100 | VTY_NEWLINE); | |
7101 | return CMD_WARNING; | |
7102 | } | |
7103 | ||
5a646650 | 7104 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
7105 | bgp_regex_free (regex); | |
7106 | return rc; | |
718e3744 | 7107 | } |
7108 | ||
7109 | DEFUN (show_ip_bgp_regexp, | |
7110 | show_ip_bgp_regexp_cmd, | |
7111 | "show ip bgp regexp .LINE", | |
7112 | SHOW_STR | |
7113 | IP_STR | |
7114 | BGP_STR | |
7115 | "Display routes matching the AS path regular expression\n" | |
7116 | "A regular-expression to match the BGP AS paths\n") | |
7117 | { | |
7118 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7119 | bgp_show_type_regexp); | |
7120 | } | |
7121 | ||
7122 | DEFUN (show_ip_bgp_flap_regexp, | |
7123 | show_ip_bgp_flap_regexp_cmd, | |
7124 | "show ip bgp flap-statistics regexp .LINE", | |
7125 | SHOW_STR | |
7126 | IP_STR | |
7127 | BGP_STR | |
7128 | "Display flap statistics of routes\n" | |
7129 | "Display routes matching the AS path regular expression\n" | |
7130 | "A regular-expression to match the BGP AS paths\n") | |
7131 | { | |
7132 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7133 | bgp_show_type_flap_regexp); | |
7134 | } | |
7135 | ||
7136 | DEFUN (show_ip_bgp_ipv4_regexp, | |
7137 | show_ip_bgp_ipv4_regexp_cmd, | |
7138 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
7139 | SHOW_STR | |
7140 | IP_STR | |
7141 | BGP_STR | |
7142 | "Address family\n" | |
7143 | "Address Family modifier\n" | |
7144 | "Address Family modifier\n" | |
7145 | "Display routes matching the AS path regular expression\n" | |
7146 | "A regular-expression to match the BGP AS paths\n") | |
7147 | { | |
7148 | if (strncmp (argv[0], "m", 1) == 0) | |
7149 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
7150 | bgp_show_type_regexp); | |
7151 | ||
7152 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7153 | bgp_show_type_regexp); | |
7154 | } | |
7155 | ||
7156 | #ifdef HAVE_IPV6 | |
7157 | DEFUN (show_bgp_regexp, | |
7158 | show_bgp_regexp_cmd, | |
7159 | "show bgp regexp .LINE", | |
7160 | SHOW_STR | |
7161 | BGP_STR | |
7162 | "Display routes matching the AS path regular expression\n" | |
7163 | "A regular-expression to match the BGP AS paths\n") | |
7164 | { | |
7165 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7166 | bgp_show_type_regexp); | |
7167 | } | |
7168 | ||
7169 | ALIAS (show_bgp_regexp, | |
7170 | show_bgp_ipv6_regexp_cmd, | |
7171 | "show bgp ipv6 regexp .LINE", | |
7172 | SHOW_STR | |
7173 | BGP_STR | |
7174 | "Address family\n" | |
7175 | "Display routes matching the AS path regular expression\n" | |
7176 | "A regular-expression to match the BGP AS paths\n") | |
7177 | ||
7178 | /* old command */ | |
7179 | DEFUN (show_ipv6_bgp_regexp, | |
7180 | show_ipv6_bgp_regexp_cmd, | |
7181 | "show ipv6 bgp regexp .LINE", | |
7182 | SHOW_STR | |
7183 | IP_STR | |
7184 | BGP_STR | |
7185 | "Display routes matching the AS path regular expression\n" | |
7186 | "A regular-expression to match the BGP AS paths\n") | |
7187 | { | |
7188 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7189 | bgp_show_type_regexp); | |
7190 | } | |
7191 | ||
7192 | /* old command */ | |
7193 | DEFUN (show_ipv6_mbgp_regexp, | |
7194 | show_ipv6_mbgp_regexp_cmd, | |
7195 | "show ipv6 mbgp regexp .LINE", | |
7196 | SHOW_STR | |
7197 | IP_STR | |
7198 | BGP_STR | |
7199 | "Display routes matching the AS path regular expression\n" | |
7200 | "A regular-expression to match the MBGP AS paths\n") | |
7201 | { | |
7202 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, | |
7203 | bgp_show_type_regexp); | |
7204 | } | |
7205 | #endif /* HAVE_IPV6 */ | |
7206 | \f | |
94f2b392 | 7207 | static int |
fd79ac91 | 7208 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
718e3744 | 7209 | safi_t safi, enum bgp_show_type type) |
7210 | { | |
7211 | struct prefix_list *plist; | |
7212 | ||
7213 | plist = prefix_list_lookup (afi, prefix_list_str); | |
7214 | if (plist == NULL) | |
7215 | { | |
7216 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
7217 | prefix_list_str, VTY_NEWLINE); | |
7218 | return CMD_WARNING; | |
7219 | } | |
7220 | ||
5a646650 | 7221 | return bgp_show (vty, NULL, afi, safi, type, plist); |
718e3744 | 7222 | } |
7223 | ||
7224 | DEFUN (show_ip_bgp_prefix_list, | |
7225 | show_ip_bgp_prefix_list_cmd, | |
7226 | "show ip bgp prefix-list WORD", | |
7227 | SHOW_STR | |
7228 | IP_STR | |
7229 | BGP_STR | |
7230 | "Display routes conforming to the prefix-list\n" | |
7231 | "IP prefix-list name\n") | |
7232 | { | |
7233 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7234 | bgp_show_type_prefix_list); | |
7235 | } | |
7236 | ||
7237 | DEFUN (show_ip_bgp_flap_prefix_list, | |
7238 | show_ip_bgp_flap_prefix_list_cmd, | |
7239 | "show ip bgp flap-statistics prefix-list WORD", | |
7240 | SHOW_STR | |
7241 | IP_STR | |
7242 | BGP_STR | |
7243 | "Display flap statistics of routes\n" | |
7244 | "Display routes conforming to the prefix-list\n" | |
7245 | "IP prefix-list name\n") | |
7246 | { | |
7247 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7248 | bgp_show_type_flap_prefix_list); | |
7249 | } | |
7250 | ||
7251 | DEFUN (show_ip_bgp_ipv4_prefix_list, | |
7252 | show_ip_bgp_ipv4_prefix_list_cmd, | |
7253 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
7254 | SHOW_STR | |
7255 | IP_STR | |
7256 | BGP_STR | |
7257 | "Address family\n" | |
7258 | "Address Family modifier\n" | |
7259 | "Address Family modifier\n" | |
7260 | "Display routes conforming to the prefix-list\n" | |
7261 | "IP prefix-list name\n") | |
7262 | { | |
7263 | if (strncmp (argv[0], "m", 1) == 0) | |
7264 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7265 | bgp_show_type_prefix_list); | |
7266 | ||
7267 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7268 | bgp_show_type_prefix_list); | |
7269 | } | |
7270 | ||
7271 | #ifdef HAVE_IPV6 | |
7272 | DEFUN (show_bgp_prefix_list, | |
7273 | show_bgp_prefix_list_cmd, | |
7274 | "show bgp prefix-list WORD", | |
7275 | SHOW_STR | |
7276 | BGP_STR | |
7277 | "Display routes conforming to the prefix-list\n" | |
7278 | "IPv6 prefix-list name\n") | |
7279 | { | |
7280 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7281 | bgp_show_type_prefix_list); | |
7282 | } | |
7283 | ||
7284 | ALIAS (show_bgp_prefix_list, | |
7285 | show_bgp_ipv6_prefix_list_cmd, | |
7286 | "show bgp ipv6 prefix-list WORD", | |
7287 | SHOW_STR | |
7288 | BGP_STR | |
7289 | "Address family\n" | |
7290 | "Display routes conforming to the prefix-list\n" | |
7291 | "IPv6 prefix-list name\n") | |
7292 | ||
7293 | /* old command */ | |
7294 | DEFUN (show_ipv6_bgp_prefix_list, | |
7295 | show_ipv6_bgp_prefix_list_cmd, | |
7296 | "show ipv6 bgp prefix-list WORD", | |
7297 | SHOW_STR | |
7298 | IPV6_STR | |
7299 | BGP_STR | |
7300 | "Display routes matching the prefix-list\n" | |
7301 | "IPv6 prefix-list name\n") | |
7302 | { | |
7303 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7304 | bgp_show_type_prefix_list); | |
7305 | } | |
7306 | ||
7307 | /* old command */ | |
7308 | DEFUN (show_ipv6_mbgp_prefix_list, | |
7309 | show_ipv6_mbgp_prefix_list_cmd, | |
7310 | "show ipv6 mbgp prefix-list WORD", | |
7311 | SHOW_STR | |
7312 | IPV6_STR | |
7313 | MBGP_STR | |
7314 | "Display routes matching the prefix-list\n" | |
7315 | "IPv6 prefix-list name\n") | |
7316 | { | |
7317 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7318 | bgp_show_type_prefix_list); | |
7319 | } | |
7320 | #endif /* HAVE_IPV6 */ | |
7321 | \f | |
94f2b392 | 7322 | static int |
fd79ac91 | 7323 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
718e3744 | 7324 | safi_t safi, enum bgp_show_type type) |
7325 | { | |
7326 | struct as_list *as_list; | |
7327 | ||
7328 | as_list = as_list_lookup (filter); | |
7329 | if (as_list == NULL) | |
7330 | { | |
7331 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
7332 | return CMD_WARNING; | |
7333 | } | |
7334 | ||
5a646650 | 7335 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
718e3744 | 7336 | } |
7337 | ||
7338 | DEFUN (show_ip_bgp_filter_list, | |
7339 | show_ip_bgp_filter_list_cmd, | |
7340 | "show ip bgp filter-list WORD", | |
7341 | SHOW_STR | |
7342 | IP_STR | |
7343 | BGP_STR | |
7344 | "Display routes conforming to the filter-list\n" | |
7345 | "Regular expression access list name\n") | |
7346 | { | |
7347 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7348 | bgp_show_type_filter_list); | |
7349 | } | |
7350 | ||
7351 | DEFUN (show_ip_bgp_flap_filter_list, | |
7352 | show_ip_bgp_flap_filter_list_cmd, | |
7353 | "show ip bgp flap-statistics filter-list WORD", | |
7354 | SHOW_STR | |
7355 | IP_STR | |
7356 | BGP_STR | |
7357 | "Display flap statistics of routes\n" | |
7358 | "Display routes conforming to the filter-list\n" | |
7359 | "Regular expression access list name\n") | |
7360 | { | |
7361 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7362 | bgp_show_type_flap_filter_list); | |
7363 | } | |
7364 | ||
7365 | DEFUN (show_ip_bgp_ipv4_filter_list, | |
7366 | show_ip_bgp_ipv4_filter_list_cmd, | |
7367 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
7368 | SHOW_STR | |
7369 | IP_STR | |
7370 | BGP_STR | |
7371 | "Address family\n" | |
7372 | "Address Family modifier\n" | |
7373 | "Address Family modifier\n" | |
7374 | "Display routes conforming to the filter-list\n" | |
7375 | "Regular expression access list name\n") | |
7376 | { | |
7377 | if (strncmp (argv[0], "m", 1) == 0) | |
7378 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7379 | bgp_show_type_filter_list); | |
7380 | ||
7381 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7382 | bgp_show_type_filter_list); | |
7383 | } | |
7384 | ||
7385 | #ifdef HAVE_IPV6 | |
7386 | DEFUN (show_bgp_filter_list, | |
7387 | show_bgp_filter_list_cmd, | |
7388 | "show bgp filter-list WORD", | |
7389 | SHOW_STR | |
7390 | BGP_STR | |
7391 | "Display routes conforming to the filter-list\n" | |
7392 | "Regular expression access list name\n") | |
7393 | { | |
7394 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7395 | bgp_show_type_filter_list); | |
7396 | } | |
7397 | ||
7398 | ALIAS (show_bgp_filter_list, | |
7399 | show_bgp_ipv6_filter_list_cmd, | |
7400 | "show bgp ipv6 filter-list WORD", | |
7401 | SHOW_STR | |
7402 | BGP_STR | |
7403 | "Address family\n" | |
7404 | "Display routes conforming to the filter-list\n" | |
7405 | "Regular expression access list name\n") | |
7406 | ||
7407 | /* old command */ | |
7408 | DEFUN (show_ipv6_bgp_filter_list, | |
7409 | show_ipv6_bgp_filter_list_cmd, | |
7410 | "show ipv6 bgp filter-list WORD", | |
7411 | SHOW_STR | |
7412 | IPV6_STR | |
7413 | BGP_STR | |
7414 | "Display routes conforming to the filter-list\n" | |
7415 | "Regular expression access list name\n") | |
7416 | { | |
7417 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7418 | bgp_show_type_filter_list); | |
7419 | } | |
7420 | ||
7421 | /* old command */ | |
7422 | DEFUN (show_ipv6_mbgp_filter_list, | |
7423 | show_ipv6_mbgp_filter_list_cmd, | |
7424 | "show ipv6 mbgp filter-list WORD", | |
7425 | SHOW_STR | |
7426 | IPV6_STR | |
7427 | MBGP_STR | |
7428 | "Display routes conforming to the filter-list\n" | |
7429 | "Regular expression access list name\n") | |
7430 | { | |
7431 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7432 | bgp_show_type_filter_list); | |
7433 | } | |
7434 | #endif /* HAVE_IPV6 */ | |
7435 | \f | |
94f2b392 | 7436 | static int |
fd79ac91 | 7437 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
718e3744 | 7438 | safi_t safi, enum bgp_show_type type) |
7439 | { | |
7440 | struct route_map *rmap; | |
7441 | ||
7442 | rmap = route_map_lookup_by_name (rmap_str); | |
7443 | if (! rmap) | |
7444 | { | |
7445 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
7446 | rmap_str, VTY_NEWLINE); | |
7447 | return CMD_WARNING; | |
7448 | } | |
7449 | ||
5a646650 | 7450 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
718e3744 | 7451 | } |
7452 | ||
7453 | DEFUN (show_ip_bgp_route_map, | |
7454 | show_ip_bgp_route_map_cmd, | |
7455 | "show ip bgp route-map WORD", | |
7456 | SHOW_STR | |
7457 | IP_STR | |
7458 | BGP_STR | |
7459 | "Display routes matching the route-map\n" | |
7460 | "A route-map to match on\n") | |
7461 | { | |
7462 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7463 | bgp_show_type_route_map); | |
7464 | } | |
7465 | ||
7466 | DEFUN (show_ip_bgp_flap_route_map, | |
7467 | show_ip_bgp_flap_route_map_cmd, | |
7468 | "show ip bgp flap-statistics route-map WORD", | |
7469 | SHOW_STR | |
7470 | IP_STR | |
7471 | BGP_STR | |
7472 | "Display flap statistics of routes\n" | |
7473 | "Display routes matching the route-map\n" | |
7474 | "A route-map to match on\n") | |
7475 | { | |
7476 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7477 | bgp_show_type_flap_route_map); | |
7478 | } | |
7479 | ||
7480 | DEFUN (show_ip_bgp_ipv4_route_map, | |
7481 | show_ip_bgp_ipv4_route_map_cmd, | |
7482 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
7483 | SHOW_STR | |
7484 | IP_STR | |
7485 | BGP_STR | |
7486 | "Address family\n" | |
7487 | "Address Family modifier\n" | |
7488 | "Address Family modifier\n" | |
7489 | "Display routes matching the route-map\n" | |
7490 | "A route-map to match on\n") | |
7491 | { | |
7492 | if (strncmp (argv[0], "m", 1) == 0) | |
7493 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7494 | bgp_show_type_route_map); | |
7495 | ||
7496 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7497 | bgp_show_type_route_map); | |
7498 | } | |
7499 | ||
7500 | DEFUN (show_bgp_route_map, | |
7501 | show_bgp_route_map_cmd, | |
7502 | "show bgp route-map WORD", | |
7503 | SHOW_STR | |
7504 | BGP_STR | |
7505 | "Display routes matching the route-map\n" | |
7506 | "A route-map to match on\n") | |
7507 | { | |
7508 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7509 | bgp_show_type_route_map); | |
7510 | } | |
7511 | ||
7512 | ALIAS (show_bgp_route_map, | |
7513 | show_bgp_ipv6_route_map_cmd, | |
7514 | "show bgp ipv6 route-map WORD", | |
7515 | SHOW_STR | |
7516 | BGP_STR | |
7517 | "Address family\n" | |
7518 | "Display routes matching the route-map\n" | |
7519 | "A route-map to match on\n") | |
7520 | \f | |
7521 | DEFUN (show_ip_bgp_cidr_only, | |
7522 | show_ip_bgp_cidr_only_cmd, | |
7523 | "show ip bgp cidr-only", | |
7524 | SHOW_STR | |
7525 | IP_STR | |
7526 | BGP_STR | |
7527 | "Display only routes with non-natural netmasks\n") | |
7528 | { | |
7529 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7530 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7531 | } |
7532 | ||
7533 | DEFUN (show_ip_bgp_flap_cidr_only, | |
7534 | show_ip_bgp_flap_cidr_only_cmd, | |
7535 | "show ip bgp flap-statistics cidr-only", | |
7536 | SHOW_STR | |
7537 | IP_STR | |
7538 | BGP_STR | |
7539 | "Display flap statistics of routes\n" | |
7540 | "Display only routes with non-natural netmasks\n") | |
7541 | { | |
7542 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7543 | bgp_show_type_flap_cidr_only, NULL); |
718e3744 | 7544 | } |
7545 | ||
7546 | DEFUN (show_ip_bgp_ipv4_cidr_only, | |
7547 | show_ip_bgp_ipv4_cidr_only_cmd, | |
7548 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
7549 | SHOW_STR | |
7550 | IP_STR | |
7551 | BGP_STR | |
7552 | "Address family\n" | |
7553 | "Address Family modifier\n" | |
7554 | "Address Family modifier\n" | |
7555 | "Display only routes with non-natural netmasks\n") | |
7556 | { | |
7557 | if (strncmp (argv[0], "m", 1) == 0) | |
7558 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7559 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7560 | |
7561 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7562 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7563 | } |
7564 | \f | |
7565 | DEFUN (show_ip_bgp_community_all, | |
7566 | show_ip_bgp_community_all_cmd, | |
7567 | "show ip bgp community", | |
7568 | SHOW_STR | |
7569 | IP_STR | |
7570 | BGP_STR | |
7571 | "Display routes matching the communities\n") | |
7572 | { | |
7573 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7574 | bgp_show_type_community_all, NULL); |
718e3744 | 7575 | } |
7576 | ||
7577 | DEFUN (show_ip_bgp_ipv4_community_all, | |
7578 | show_ip_bgp_ipv4_community_all_cmd, | |
7579 | "show ip bgp ipv4 (unicast|multicast) community", | |
7580 | SHOW_STR | |
7581 | IP_STR | |
7582 | BGP_STR | |
7583 | "Address family\n" | |
7584 | "Address Family modifier\n" | |
7585 | "Address Family modifier\n" | |
7586 | "Display routes matching the communities\n") | |
7587 | { | |
7588 | if (strncmp (argv[0], "m", 1) == 0) | |
7589 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7590 | bgp_show_type_community_all, NULL); |
718e3744 | 7591 | |
7592 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7593 | bgp_show_type_community_all, NULL); |
718e3744 | 7594 | } |
7595 | ||
7596 | #ifdef HAVE_IPV6 | |
7597 | DEFUN (show_bgp_community_all, | |
7598 | show_bgp_community_all_cmd, | |
7599 | "show bgp community", | |
7600 | SHOW_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 | ALIAS (show_bgp_community_all, | |
7609 | show_bgp_ipv6_community_all_cmd, | |
7610 | "show bgp ipv6 community", | |
7611 | SHOW_STR | |
7612 | BGP_STR | |
7613 | "Address family\n" | |
7614 | "Display routes matching the communities\n") | |
7615 | ||
7616 | /* old command */ | |
7617 | DEFUN (show_ipv6_bgp_community_all, | |
7618 | show_ipv6_bgp_community_all_cmd, | |
7619 | "show ipv6 bgp community", | |
7620 | SHOW_STR | |
7621 | IPV6_STR | |
7622 | BGP_STR | |
7623 | "Display routes matching the communities\n") | |
7624 | { | |
7625 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7626 | bgp_show_type_community_all, NULL); |
718e3744 | 7627 | } |
7628 | ||
7629 | /* old command */ | |
7630 | DEFUN (show_ipv6_mbgp_community_all, | |
7631 | show_ipv6_mbgp_community_all_cmd, | |
7632 | "show ipv6 mbgp community", | |
7633 | SHOW_STR | |
7634 | IPV6_STR | |
7635 | MBGP_STR | |
7636 | "Display routes matching the communities\n") | |
7637 | { | |
7638 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, | |
5a646650 | 7639 | bgp_show_type_community_all, NULL); |
718e3744 | 7640 | } |
7641 | #endif /* HAVE_IPV6 */ | |
7642 | \f | |
94f2b392 | 7643 | static int |
95cbbd2a ML |
7644 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
7645 | const char **argv, int exact, afi_t afi, safi_t safi) | |
718e3744 | 7646 | { |
7647 | struct community *com; | |
7648 | struct buffer *b; | |
95cbbd2a | 7649 | struct bgp *bgp; |
718e3744 | 7650 | int i; |
7651 | char *str; | |
7652 | int first = 0; | |
7653 | ||
95cbbd2a ML |
7654 | /* BGP structure lookup */ |
7655 | if (view_name) | |
7656 | { | |
7657 | bgp = bgp_lookup_by_name (view_name); | |
7658 | if (bgp == NULL) | |
7659 | { | |
7660 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
7661 | return CMD_WARNING; | |
7662 | } | |
7663 | } | |
7664 | else | |
7665 | { | |
7666 | bgp = bgp_get_default (); | |
7667 | if (bgp == NULL) | |
7668 | { | |
7669 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
7670 | return CMD_WARNING; | |
7671 | } | |
7672 | } | |
7673 | ||
718e3744 | 7674 | b = buffer_new (1024); |
7675 | for (i = 0; i < argc; i++) | |
7676 | { | |
7677 | if (first) | |
7678 | buffer_putc (b, ' '); | |
7679 | else | |
7680 | { | |
7681 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7682 | continue; | |
7683 | first = 1; | |
7684 | } | |
7685 | ||
7686 | buffer_putstr (b, argv[i]); | |
7687 | } | |
7688 | buffer_putc (b, '\0'); | |
7689 | ||
7690 | str = buffer_getstr (b); | |
7691 | buffer_free (b); | |
7692 | ||
7693 | com = community_str2com (str); | |
3b8b1855 | 7694 | XFREE (MTYPE_TMP, str); |
718e3744 | 7695 | if (! com) |
7696 | { | |
7697 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
7698 | return CMD_WARNING; | |
7699 | } | |
7700 | ||
95cbbd2a | 7701 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 7702 | (exact ? bgp_show_type_community_exact : |
7703 | bgp_show_type_community), com); | |
718e3744 | 7704 | } |
7705 | ||
7706 | DEFUN (show_ip_bgp_community, | |
7707 | show_ip_bgp_community_cmd, | |
7708 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
7709 | SHOW_STR | |
7710 | IP_STR | |
7711 | BGP_STR | |
7712 | "Display routes matching the communities\n" | |
7713 | "community number\n" | |
7714 | "Do not send outside local AS (well-known community)\n" | |
7715 | "Do not advertise to any peer (well-known community)\n" | |
7716 | "Do not export to next AS (well-known community)\n") | |
7717 | { | |
95cbbd2a | 7718 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 7719 | } |
7720 | ||
7721 | ALIAS (show_ip_bgp_community, | |
7722 | show_ip_bgp_community2_cmd, | |
7723 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7724 | SHOW_STR | |
7725 | IP_STR | |
7726 | BGP_STR | |
7727 | "Display routes matching the communities\n" | |
7728 | "community number\n" | |
7729 | "Do not send outside local AS (well-known community)\n" | |
7730 | "Do not advertise to any peer (well-known community)\n" | |
7731 | "Do not export to next AS (well-known community)\n" | |
7732 | "community number\n" | |
7733 | "Do not send outside local AS (well-known community)\n" | |
7734 | "Do not advertise to any peer (well-known community)\n" | |
7735 | "Do not export to next AS (well-known community)\n") | |
7736 | ||
7737 | ALIAS (show_ip_bgp_community, | |
7738 | show_ip_bgp_community3_cmd, | |
7739 | "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)", | |
7740 | SHOW_STR | |
7741 | IP_STR | |
7742 | BGP_STR | |
7743 | "Display routes matching the communities\n" | |
7744 | "community number\n" | |
7745 | "Do not send outside local AS (well-known community)\n" | |
7746 | "Do not advertise to any peer (well-known community)\n" | |
7747 | "Do not export to next AS (well-known community)\n" | |
7748 | "community number\n" | |
7749 | "Do not send outside local AS (well-known community)\n" | |
7750 | "Do not advertise to any peer (well-known community)\n" | |
7751 | "Do not export to next AS (well-known community)\n" | |
7752 | "community number\n" | |
7753 | "Do not send outside local AS (well-known community)\n" | |
7754 | "Do not advertise to any peer (well-known community)\n" | |
7755 | "Do not export to next AS (well-known community)\n") | |
7756 | ||
7757 | ALIAS (show_ip_bgp_community, | |
7758 | show_ip_bgp_community4_cmd, | |
7759 | "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)", | |
7760 | SHOW_STR | |
7761 | IP_STR | |
7762 | BGP_STR | |
7763 | "Display routes matching the communities\n" | |
7764 | "community number\n" | |
7765 | "Do not send outside local AS (well-known community)\n" | |
7766 | "Do not advertise to any peer (well-known community)\n" | |
7767 | "Do not export to next AS (well-known community)\n" | |
7768 | "community number\n" | |
7769 | "Do not send outside local AS (well-known community)\n" | |
7770 | "Do not advertise to any peer (well-known community)\n" | |
7771 | "Do not export to next AS (well-known community)\n" | |
7772 | "community number\n" | |
7773 | "Do not send outside local AS (well-known community)\n" | |
7774 | "Do not advertise to any peer (well-known community)\n" | |
7775 | "Do not export to next AS (well-known community)\n" | |
7776 | "community number\n" | |
7777 | "Do not send outside local AS (well-known community)\n" | |
7778 | "Do not advertise to any peer (well-known community)\n" | |
7779 | "Do not export to next AS (well-known community)\n") | |
7780 | ||
7781 | DEFUN (show_ip_bgp_ipv4_community, | |
7782 | show_ip_bgp_ipv4_community_cmd, | |
7783 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7784 | SHOW_STR | |
7785 | IP_STR | |
7786 | BGP_STR | |
7787 | "Address family\n" | |
7788 | "Address Family modifier\n" | |
7789 | "Address Family modifier\n" | |
7790 | "Display routes matching the communities\n" | |
7791 | "community number\n" | |
7792 | "Do not send outside local AS (well-known community)\n" | |
7793 | "Do not advertise to any peer (well-known community)\n" | |
7794 | "Do not export to next AS (well-known community)\n") | |
7795 | { | |
7796 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 7797 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 7798 | |
95cbbd2a | 7799 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 7800 | } |
7801 | ||
7802 | ALIAS (show_ip_bgp_ipv4_community, | |
7803 | show_ip_bgp_ipv4_community2_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)", | |
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 | ||
7821 | ALIAS (show_ip_bgp_ipv4_community, | |
7822 | show_ip_bgp_ipv4_community3_cmd, | |
7823 | "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)", | |
7824 | SHOW_STR | |
7825 | IP_STR | |
7826 | BGP_STR | |
7827 | "Address family\n" | |
7828 | "Address Family modifier\n" | |
7829 | "Address Family modifier\n" | |
7830 | "Display routes matching the communities\n" | |
7831 | "community number\n" | |
7832 | "Do not send outside local AS (well-known community)\n" | |
7833 | "Do not advertise to any peer (well-known community)\n" | |
7834 | "Do not export to next AS (well-known community)\n" | |
7835 | "community number\n" | |
7836 | "Do not send outside local AS (well-known community)\n" | |
7837 | "Do not advertise to any peer (well-known community)\n" | |
7838 | "Do not export to next AS (well-known community)\n" | |
7839 | "community number\n" | |
7840 | "Do not send outside local AS (well-known community)\n" | |
7841 | "Do not advertise to any peer (well-known community)\n" | |
7842 | "Do not export to next AS (well-known community)\n") | |
7843 | ||
7844 | ALIAS (show_ip_bgp_ipv4_community, | |
7845 | show_ip_bgp_ipv4_community4_cmd, | |
7846 | "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)", | |
7847 | SHOW_STR | |
7848 | IP_STR | |
7849 | BGP_STR | |
7850 | "Address family\n" | |
7851 | "Address Family modifier\n" | |
7852 | "Address Family modifier\n" | |
7853 | "Display routes matching the communities\n" | |
7854 | "community number\n" | |
7855 | "Do not send outside local AS (well-known community)\n" | |
7856 | "Do not advertise to any peer (well-known community)\n" | |
7857 | "Do not export to next AS (well-known community)\n" | |
7858 | "community number\n" | |
7859 | "Do not send outside local AS (well-known community)\n" | |
7860 | "Do not advertise to any peer (well-known community)\n" | |
7861 | "Do not export to next AS (well-known community)\n" | |
7862 | "community number\n" | |
7863 | "Do not send outside local AS (well-known community)\n" | |
7864 | "Do not advertise to any peer (well-known community)\n" | |
7865 | "Do not export to next AS (well-known community)\n" | |
7866 | "community number\n" | |
7867 | "Do not send outside local AS (well-known community)\n" | |
7868 | "Do not advertise to any peer (well-known community)\n" | |
7869 | "Do not export to next AS (well-known community)\n") | |
7870 | ||
95cbbd2a ML |
7871 | DEFUN (show_bgp_view_afi_safi_community_all, |
7872 | show_bgp_view_afi_safi_community_all_cmd, | |
7873 | #ifdef HAVE_IPV6 | |
7874 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", | |
7875 | #else | |
7876 | "show bgp view WORD ipv4 (unicast|multicast) community", | |
7877 | #endif | |
7878 | SHOW_STR | |
7879 | BGP_STR | |
7880 | "BGP view\n" | |
7881 | "BGP view name\n" | |
7882 | "Address family\n" | |
7883 | #ifdef HAVE_IPV6 | |
7884 | "Address family\n" | |
7885 | #endif | |
7886 | "Address Family modifier\n" | |
7887 | "Address Family modifier\n" | |
7888 | "Display routes containing communities\n") | |
7889 | { | |
7890 | int afi; | |
7891 | int safi; | |
7892 | struct bgp *bgp; | |
7893 | ||
7894 | /* BGP structure lookup. */ | |
7895 | bgp = bgp_lookup_by_name (argv[0]); | |
7896 | if (bgp == NULL) | |
7897 | { | |
7898 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
7899 | return CMD_WARNING; | |
7900 | } | |
7901 | ||
7902 | #ifdef HAVE_IPV6 | |
7903 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
7904 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7905 | #else | |
7906 | afi = AFI_IP; | |
7907 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7908 | #endif | |
7909 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); | |
7910 | } | |
7911 | ||
7912 | DEFUN (show_bgp_view_afi_safi_community, | |
7913 | show_bgp_view_afi_safi_community_cmd, | |
7914 | #ifdef HAVE_IPV6 | |
7915 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7916 | #else | |
7917 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7918 | #endif | |
7919 | SHOW_STR | |
7920 | BGP_STR | |
7921 | "BGP view\n" | |
7922 | "BGP view name\n" | |
7923 | "Address family\n" | |
7924 | #ifdef HAVE_IPV6 | |
7925 | "Address family\n" | |
7926 | #endif | |
7927 | "Address family modifier\n" | |
7928 | "Address family modifier\n" | |
7929 | "Display routes matching the communities\n" | |
7930 | "community number\n" | |
7931 | "Do not send outside local AS (well-known community)\n" | |
7932 | "Do not advertise to any peer (well-known community)\n" | |
7933 | "Do not export to next AS (well-known community)\n") | |
7934 | { | |
7935 | int afi; | |
7936 | int safi; | |
7937 | ||
7938 | #ifdef HAVE_IPV6 | |
7939 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
7940 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7941 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); | |
7942 | #else | |
7943 | afi = AFI_IP; | |
7944 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7945 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); | |
7946 | #endif | |
7947 | } | |
7948 | ||
7949 | ALIAS (show_bgp_view_afi_safi_community, | |
7950 | show_bgp_view_afi_safi_community2_cmd, | |
7951 | #ifdef HAVE_IPV6 | |
7952 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7953 | #else | |
7954 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7955 | #endif | |
7956 | SHOW_STR | |
7957 | BGP_STR | |
7958 | "BGP view\n" | |
7959 | "BGP view name\n" | |
7960 | "Address family\n" | |
7961 | #ifdef HAVE_IPV6 | |
7962 | "Address family\n" | |
7963 | #endif | |
7964 | "Address family modifier\n" | |
7965 | "Address family modifier\n" | |
7966 | "Display routes matching the communities\n" | |
7967 | "community number\n" | |
7968 | "Do not send outside local AS (well-known community)\n" | |
7969 | "Do not advertise to any peer (well-known community)\n" | |
7970 | "Do not export to next AS (well-known community)\n" | |
7971 | "community number\n" | |
7972 | "Do not send outside local AS (well-known community)\n" | |
7973 | "Do not advertise to any peer (well-known community)\n" | |
7974 | "Do not export to next AS (well-known community)\n") | |
7975 | ||
7976 | ALIAS (show_bgp_view_afi_safi_community, | |
7977 | show_bgp_view_afi_safi_community3_cmd, | |
7978 | #ifdef HAVE_IPV6 | |
7979 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7980 | #else | |
7981 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7982 | #endif | |
7983 | SHOW_STR | |
7984 | BGP_STR | |
7985 | "BGP view\n" | |
7986 | "BGP view name\n" | |
7987 | "Address family\n" | |
7988 | #ifdef HAVE_IPV6 | |
7989 | "Address family\n" | |
7990 | #endif | |
7991 | "Address family modifier\n" | |
7992 | "Address family modifier\n" | |
7993 | "Display routes matching the communities\n" | |
7994 | "community number\n" | |
7995 | "Do not send outside local AS (well-known community)\n" | |
7996 | "Do not advertise to any peer (well-known community)\n" | |
7997 | "Do not export to next AS (well-known community)\n" | |
7998 | "community number\n" | |
7999 | "Do not send outside local AS (well-known community)\n" | |
8000 | "Do not advertise to any peer (well-known community)\n" | |
8001 | "Do not export to next AS (well-known community)\n" | |
8002 | "community number\n" | |
8003 | "Do not send outside local AS (well-known community)\n" | |
8004 | "Do not advertise to any peer (well-known community)\n" | |
8005 | "Do not export to next AS (well-known community)\n") | |
8006 | ||
8007 | ALIAS (show_bgp_view_afi_safi_community, | |
8008 | show_bgp_view_afi_safi_community4_cmd, | |
8009 | #ifdef HAVE_IPV6 | |
8010 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8011 | #else | |
8012 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8013 | #endif | |
8014 | SHOW_STR | |
8015 | BGP_STR | |
8016 | "BGP view\n" | |
8017 | "BGP view name\n" | |
8018 | "Address family\n" | |
8019 | #ifdef HAVE_IPV6 | |
8020 | "Address family\n" | |
8021 | #endif | |
8022 | "Address family modifier\n" | |
8023 | "Address family modifier\n" | |
8024 | "Display routes matching the communities\n" | |
8025 | "community number\n" | |
8026 | "Do not send outside local AS (well-known community)\n" | |
8027 | "Do not advertise to any peer (well-known community)\n" | |
8028 | "Do not export to next AS (well-known community)\n" | |
8029 | "community number\n" | |
8030 | "Do not send outside local AS (well-known community)\n" | |
8031 | "Do not advertise to any peer (well-known community)\n" | |
8032 | "Do not export to next AS (well-known community)\n" | |
8033 | "community number\n" | |
8034 | "Do not send outside local AS (well-known community)\n" | |
8035 | "Do not advertise to any peer (well-known community)\n" | |
8036 | "Do not export to next AS (well-known community)\n" | |
8037 | "community number\n" | |
8038 | "Do not send outside local AS (well-known community)\n" | |
8039 | "Do not advertise to any peer (well-known community)\n" | |
8040 | "Do not export to next AS (well-known community)\n") | |
8041 | ||
718e3744 | 8042 | DEFUN (show_ip_bgp_community_exact, |
8043 | show_ip_bgp_community_exact_cmd, | |
8044 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8045 | SHOW_STR | |
8046 | IP_STR | |
8047 | BGP_STR | |
8048 | "Display routes matching the communities\n" | |
8049 | "community number\n" | |
8050 | "Do not send outside local AS (well-known community)\n" | |
8051 | "Do not advertise to any peer (well-known community)\n" | |
8052 | "Do not export to next AS (well-known community)\n" | |
8053 | "Exact match of the communities") | |
8054 | { | |
95cbbd2a | 8055 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 8056 | } |
8057 | ||
8058 | ALIAS (show_ip_bgp_community_exact, | |
8059 | show_ip_bgp_community2_exact_cmd, | |
8060 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8061 | SHOW_STR | |
8062 | IP_STR | |
8063 | BGP_STR | |
8064 | "Display routes matching the communities\n" | |
8065 | "community number\n" | |
8066 | "Do not send outside local AS (well-known community)\n" | |
8067 | "Do not advertise to any peer (well-known community)\n" | |
8068 | "Do not export to next AS (well-known community)\n" | |
8069 | "community number\n" | |
8070 | "Do not send outside local AS (well-known community)\n" | |
8071 | "Do not advertise to any peer (well-known community)\n" | |
8072 | "Do not export to next AS (well-known community)\n" | |
8073 | "Exact match of the communities") | |
8074 | ||
8075 | ALIAS (show_ip_bgp_community_exact, | |
8076 | show_ip_bgp_community3_exact_cmd, | |
8077 | "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", | |
8078 | SHOW_STR | |
8079 | IP_STR | |
8080 | BGP_STR | |
8081 | "Display routes matching the communities\n" | |
8082 | "community number\n" | |
8083 | "Do not send outside local AS (well-known community)\n" | |
8084 | "Do not advertise to any peer (well-known community)\n" | |
8085 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") | |
8095 | ||
8096 | ALIAS (show_ip_bgp_community_exact, | |
8097 | show_ip_bgp_community4_exact_cmd, | |
8098 | "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", | |
8099 | SHOW_STR | |
8100 | IP_STR | |
8101 | BGP_STR | |
8102 | "Display routes matching the communities\n" | |
8103 | "community number\n" | |
8104 | "Do not send outside local AS (well-known community)\n" | |
8105 | "Do not advertise to any peer (well-known community)\n" | |
8106 | "Do not export to next AS (well-known community)\n" | |
8107 | "community number\n" | |
8108 | "Do not send outside local AS (well-known community)\n" | |
8109 | "Do not advertise to any peer (well-known community)\n" | |
8110 | "Do not export to next AS (well-known community)\n" | |
8111 | "community number\n" | |
8112 | "Do not send outside local AS (well-known community)\n" | |
8113 | "Do not advertise to any peer (well-known community)\n" | |
8114 | "Do not export to next AS (well-known community)\n" | |
8115 | "community number\n" | |
8116 | "Do not send outside local AS (well-known community)\n" | |
8117 | "Do not advertise to any peer (well-known community)\n" | |
8118 | "Do not export to next AS (well-known community)\n" | |
8119 | "Exact match of the communities") | |
8120 | ||
8121 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
8122 | show_ip_bgp_ipv4_community_exact_cmd, | |
8123 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8124 | SHOW_STR | |
8125 | IP_STR | |
8126 | BGP_STR | |
8127 | "Address family\n" | |
8128 | "Address Family modifier\n" | |
8129 | "Address Family modifier\n" | |
8130 | "Display routes matching the communities\n" | |
8131 | "community number\n" | |
8132 | "Do not send outside local AS (well-known community)\n" | |
8133 | "Do not advertise to any peer (well-known community)\n" | |
8134 | "Do not export to next AS (well-known community)\n" | |
8135 | "Exact match of the communities") | |
8136 | { | |
8137 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 8138 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 8139 | |
95cbbd2a | 8140 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 8141 | } |
8142 | ||
8143 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8144 | show_ip_bgp_ipv4_community2_exact_cmd, | |
8145 | "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", | |
8146 | SHOW_STR | |
8147 | IP_STR | |
8148 | BGP_STR | |
8149 | "Address family\n" | |
8150 | "Address Family modifier\n" | |
8151 | "Address Family modifier\n" | |
8152 | "Display routes matching the communities\n" | |
8153 | "community number\n" | |
8154 | "Do not send outside local AS (well-known community)\n" | |
8155 | "Do not advertise to any peer (well-known community)\n" | |
8156 | "Do not export to next AS (well-known community)\n" | |
8157 | "community number\n" | |
8158 | "Do not send outside local AS (well-known community)\n" | |
8159 | "Do not advertise to any peer (well-known community)\n" | |
8160 | "Do not export to next AS (well-known community)\n" | |
8161 | "Exact match of the communities") | |
8162 | ||
8163 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8164 | show_ip_bgp_ipv4_community3_exact_cmd, | |
8165 | "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", | |
8166 | SHOW_STR | |
8167 | IP_STR | |
8168 | BGP_STR | |
8169 | "Address family\n" | |
8170 | "Address Family modifier\n" | |
8171 | "Address Family modifier\n" | |
8172 | "Display routes matching the communities\n" | |
8173 | "community number\n" | |
8174 | "Do not send outside local AS (well-known community)\n" | |
8175 | "Do not advertise to any peer (well-known community)\n" | |
8176 | "Do not export to next AS (well-known community)\n" | |
8177 | "community number\n" | |
8178 | "Do not send outside local AS (well-known community)\n" | |
8179 | "Do not advertise to any peer (well-known community)\n" | |
8180 | "Do not export to next AS (well-known community)\n" | |
8181 | "community number\n" | |
8182 | "Do not send outside local AS (well-known community)\n" | |
8183 | "Do not advertise to any peer (well-known community)\n" | |
8184 | "Do not export to next AS (well-known community)\n" | |
8185 | "Exact match of the communities") | |
8186 | ||
8187 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8188 | show_ip_bgp_ipv4_community4_exact_cmd, | |
8189 | "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", | |
8190 | SHOW_STR | |
8191 | IP_STR | |
8192 | BGP_STR | |
8193 | "Address family\n" | |
8194 | "Address Family modifier\n" | |
8195 | "Address Family modifier\n" | |
8196 | "Display routes matching the communities\n" | |
8197 | "community number\n" | |
8198 | "Do not send outside local AS (well-known community)\n" | |
8199 | "Do not advertise to any peer (well-known community)\n" | |
8200 | "Do not export to next AS (well-known community)\n" | |
8201 | "community number\n" | |
8202 | "Do not send outside local AS (well-known community)\n" | |
8203 | "Do not advertise to any peer (well-known community)\n" | |
8204 | "Do not export to next AS (well-known community)\n" | |
8205 | "community number\n" | |
8206 | "Do not send outside local AS (well-known community)\n" | |
8207 | "Do not advertise to any peer (well-known community)\n" | |
8208 | "Do not export to next AS (well-known community)\n" | |
8209 | "community number\n" | |
8210 | "Do not send outside local AS (well-known community)\n" | |
8211 | "Do not advertise to any peer (well-known community)\n" | |
8212 | "Do not export to next AS (well-known community)\n" | |
8213 | "Exact match of the communities") | |
8214 | ||
8215 | #ifdef HAVE_IPV6 | |
8216 | DEFUN (show_bgp_community, | |
8217 | show_bgp_community_cmd, | |
8218 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8219 | SHOW_STR | |
8220 | BGP_STR | |
8221 | "Display routes matching the communities\n" | |
8222 | "community number\n" | |
8223 | "Do not send outside local AS (well-known community)\n" | |
8224 | "Do not advertise to any peer (well-known community)\n" | |
8225 | "Do not export to next AS (well-known community)\n") | |
8226 | { | |
95cbbd2a | 8227 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8228 | } |
8229 | ||
8230 | ALIAS (show_bgp_community, | |
8231 | show_bgp_ipv6_community_cmd, | |
8232 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
8233 | SHOW_STR | |
8234 | BGP_STR | |
8235 | "Address family\n" | |
8236 | "Display routes matching the communities\n" | |
8237 | "community number\n" | |
8238 | "Do not send outside local AS (well-known community)\n" | |
8239 | "Do not advertise to any peer (well-known community)\n" | |
8240 | "Do not export to next AS (well-known community)\n") | |
8241 | ||
8242 | ALIAS (show_bgp_community, | |
8243 | show_bgp_community2_cmd, | |
8244 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8245 | SHOW_STR | |
8246 | BGP_STR | |
8247 | "Display routes matching the communities\n" | |
8248 | "community number\n" | |
8249 | "Do not send outside local AS (well-known community)\n" | |
8250 | "Do not advertise to any peer (well-known community)\n" | |
8251 | "Do not export to next AS (well-known community)\n" | |
8252 | "community number\n" | |
8253 | "Do not send outside local AS (well-known community)\n" | |
8254 | "Do not advertise to any peer (well-known community)\n" | |
8255 | "Do not export to next AS (well-known community)\n") | |
8256 | ||
8257 | ALIAS (show_bgp_community, | |
8258 | show_bgp_ipv6_community2_cmd, | |
8259 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8260 | SHOW_STR | |
8261 | BGP_STR | |
8262 | "Address family\n" | |
8263 | "Display routes matching the communities\n" | |
8264 | "community number\n" | |
8265 | "Do not send outside local AS (well-known community)\n" | |
8266 | "Do not advertise to any peer (well-known community)\n" | |
8267 | "Do not export to next AS (well-known community)\n" | |
8268 | "community number\n" | |
8269 | "Do not send outside local AS (well-known community)\n" | |
8270 | "Do not advertise to any peer (well-known community)\n" | |
8271 | "Do not export to next AS (well-known community)\n") | |
8272 | ||
8273 | ALIAS (show_bgp_community, | |
8274 | show_bgp_community3_cmd, | |
8275 | "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)", | |
8276 | SHOW_STR | |
8277 | BGP_STR | |
8278 | "Display routes matching the communities\n" | |
8279 | "community number\n" | |
8280 | "Do not send outside local AS (well-known community)\n" | |
8281 | "Do not advertise to any peer (well-known community)\n" | |
8282 | "Do not export to next AS (well-known community)\n" | |
8283 | "community number\n" | |
8284 | "Do not send outside local AS (well-known community)\n" | |
8285 | "Do not advertise to any peer (well-known community)\n" | |
8286 | "Do not export to next AS (well-known community)\n" | |
8287 | "community number\n" | |
8288 | "Do not send outside local AS (well-known community)\n" | |
8289 | "Do not advertise to any peer (well-known community)\n" | |
8290 | "Do not export to next AS (well-known community)\n") | |
8291 | ||
8292 | ALIAS (show_bgp_community, | |
8293 | show_bgp_ipv6_community3_cmd, | |
8294 | "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)", | |
8295 | SHOW_STR | |
8296 | BGP_STR | |
8297 | "Address family\n" | |
8298 | "Display routes matching the communities\n" | |
8299 | "community number\n" | |
8300 | "Do not send outside local AS (well-known community)\n" | |
8301 | "Do not advertise to any peer (well-known community)\n" | |
8302 | "Do not export to next AS (well-known community)\n" | |
8303 | "community number\n" | |
8304 | "Do not send outside local AS (well-known community)\n" | |
8305 | "Do not advertise to any peer (well-known community)\n" | |
8306 | "Do not export to next AS (well-known community)\n" | |
8307 | "community number\n" | |
8308 | "Do not send outside local AS (well-known community)\n" | |
8309 | "Do not advertise to any peer (well-known community)\n" | |
8310 | "Do not export to next AS (well-known community)\n") | |
8311 | ||
8312 | ALIAS (show_bgp_community, | |
8313 | show_bgp_community4_cmd, | |
8314 | "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)", | |
8315 | SHOW_STR | |
8316 | BGP_STR | |
8317 | "Display routes matching the communities\n" | |
8318 | "community number\n" | |
8319 | "Do not send outside local AS (well-known community)\n" | |
8320 | "Do not advertise to any peer (well-known community)\n" | |
8321 | "Do not export to next AS (well-known community)\n" | |
8322 | "community number\n" | |
8323 | "Do not send outside local AS (well-known community)\n" | |
8324 | "Do not advertise to any peer (well-known community)\n" | |
8325 | "Do not export to next AS (well-known community)\n" | |
8326 | "community number\n" | |
8327 | "Do not send outside local AS (well-known community)\n" | |
8328 | "Do not advertise to any peer (well-known community)\n" | |
8329 | "Do not export to next AS (well-known community)\n" | |
8330 | "community number\n" | |
8331 | "Do not send outside local AS (well-known community)\n" | |
8332 | "Do not advertise to any peer (well-known community)\n" | |
8333 | "Do not export to next AS (well-known community)\n") | |
8334 | ||
8335 | ALIAS (show_bgp_community, | |
8336 | show_bgp_ipv6_community4_cmd, | |
8337 | "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)", | |
8338 | SHOW_STR | |
8339 | BGP_STR | |
8340 | "Address family\n" | |
8341 | "Display routes matching the communities\n" | |
8342 | "community number\n" | |
8343 | "Do not send outside local AS (well-known community)\n" | |
8344 | "Do not advertise to any peer (well-known community)\n" | |
8345 | "Do not export to next AS (well-known community)\n" | |
8346 | "community number\n" | |
8347 | "Do not send outside local AS (well-known community)\n" | |
8348 | "Do not advertise to any peer (well-known community)\n" | |
8349 | "Do not export to next AS (well-known community)\n" | |
8350 | "community number\n" | |
8351 | "Do not send outside local AS (well-known community)\n" | |
8352 | "Do not advertise to any peer (well-known community)\n" | |
8353 | "Do not export to next AS (well-known community)\n" | |
8354 | "community number\n" | |
8355 | "Do not send outside local AS (well-known community)\n" | |
8356 | "Do not advertise to any peer (well-known community)\n" | |
8357 | "Do not export to next AS (well-known community)\n") | |
8358 | ||
8359 | /* old command */ | |
8360 | DEFUN (show_ipv6_bgp_community, | |
8361 | show_ipv6_bgp_community_cmd, | |
8362 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8363 | SHOW_STR | |
8364 | IPV6_STR | |
8365 | BGP_STR | |
8366 | "Display routes matching the communities\n" | |
8367 | "community number\n" | |
8368 | "Do not send outside local AS (well-known community)\n" | |
8369 | "Do not advertise to any peer (well-known community)\n" | |
8370 | "Do not export to next AS (well-known community)\n") | |
8371 | { | |
95cbbd2a | 8372 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8373 | } |
8374 | ||
8375 | /* old command */ | |
8376 | ALIAS (show_ipv6_bgp_community, | |
8377 | show_ipv6_bgp_community2_cmd, | |
8378 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8379 | SHOW_STR | |
8380 | IPV6_STR | |
8381 | BGP_STR | |
8382 | "Display routes matching the communities\n" | |
8383 | "community number\n" | |
8384 | "Do not send outside local AS (well-known community)\n" | |
8385 | "Do not advertise to any peer (well-known community)\n" | |
8386 | "Do not export to next AS (well-known community)\n" | |
8387 | "community number\n" | |
8388 | "Do not send outside local AS (well-known community)\n" | |
8389 | "Do not advertise to any peer (well-known community)\n" | |
8390 | "Do not export to next AS (well-known community)\n") | |
8391 | ||
8392 | /* old command */ | |
8393 | ALIAS (show_ipv6_bgp_community, | |
8394 | show_ipv6_bgp_community3_cmd, | |
8395 | "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)", | |
8396 | SHOW_STR | |
8397 | IPV6_STR | |
8398 | BGP_STR | |
8399 | "Display routes matching the communities\n" | |
8400 | "community number\n" | |
8401 | "Do not send outside local AS (well-known community)\n" | |
8402 | "Do not advertise to any peer (well-known community)\n" | |
8403 | "Do not export to next AS (well-known community)\n" | |
8404 | "community number\n" | |
8405 | "Do not send outside local AS (well-known community)\n" | |
8406 | "Do not advertise to any peer (well-known community)\n" | |
8407 | "Do not export to next AS (well-known community)\n" | |
8408 | "community number\n" | |
8409 | "Do not send outside local AS (well-known community)\n" | |
8410 | "Do not advertise to any peer (well-known community)\n" | |
8411 | "Do not export to next AS (well-known community)\n") | |
8412 | ||
8413 | /* old command */ | |
8414 | ALIAS (show_ipv6_bgp_community, | |
8415 | show_ipv6_bgp_community4_cmd, | |
8416 | "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)", | |
8417 | SHOW_STR | |
8418 | IPV6_STR | |
8419 | BGP_STR | |
8420 | "Display routes matching the communities\n" | |
8421 | "community number\n" | |
8422 | "Do not send outside local AS (well-known community)\n" | |
8423 | "Do not advertise to any peer (well-known community)\n" | |
8424 | "Do not export to next AS (well-known community)\n" | |
8425 | "community number\n" | |
8426 | "Do not send outside local AS (well-known community)\n" | |
8427 | "Do not advertise to any peer (well-known community)\n" | |
8428 | "Do not export to next AS (well-known community)\n" | |
8429 | "community number\n" | |
8430 | "Do not send outside local AS (well-known community)\n" | |
8431 | "Do not advertise to any peer (well-known community)\n" | |
8432 | "Do not export to next AS (well-known community)\n" | |
8433 | "community number\n" | |
8434 | "Do not send outside local AS (well-known community)\n" | |
8435 | "Do not advertise to any peer (well-known community)\n" | |
8436 | "Do not export to next AS (well-known community)\n") | |
8437 | ||
8438 | DEFUN (show_bgp_community_exact, | |
8439 | show_bgp_community_exact_cmd, | |
8440 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8441 | SHOW_STR | |
8442 | BGP_STR | |
8443 | "Display routes matching the communities\n" | |
8444 | "community number\n" | |
8445 | "Do not send outside local AS (well-known community)\n" | |
8446 | "Do not advertise to any peer (well-known community)\n" | |
8447 | "Do not export to next AS (well-known community)\n" | |
8448 | "Exact match of the communities") | |
8449 | { | |
95cbbd2a | 8450 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8451 | } |
8452 | ||
8453 | ALIAS (show_bgp_community_exact, | |
8454 | show_bgp_ipv6_community_exact_cmd, | |
8455 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8456 | SHOW_STR | |
8457 | BGP_STR | |
8458 | "Address family\n" | |
8459 | "Display routes matching the communities\n" | |
8460 | "community number\n" | |
8461 | "Do not send outside local AS (well-known community)\n" | |
8462 | "Do not advertise to any peer (well-known community)\n" | |
8463 | "Do not export to next AS (well-known community)\n" | |
8464 | "Exact match of the communities") | |
8465 | ||
8466 | ALIAS (show_bgp_community_exact, | |
8467 | show_bgp_community2_exact_cmd, | |
8468 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8469 | SHOW_STR | |
8470 | BGP_STR | |
8471 | "Display routes matching the communities\n" | |
8472 | "community number\n" | |
8473 | "Do not send outside local AS (well-known community)\n" | |
8474 | "Do not advertise to any peer (well-known community)\n" | |
8475 | "Do not export to next AS (well-known community)\n" | |
8476 | "community number\n" | |
8477 | "Do not send outside local AS (well-known community)\n" | |
8478 | "Do not advertise to any peer (well-known community)\n" | |
8479 | "Do not export to next AS (well-known community)\n" | |
8480 | "Exact match of the communities") | |
8481 | ||
8482 | ALIAS (show_bgp_community_exact, | |
8483 | show_bgp_ipv6_community2_exact_cmd, | |
8484 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8485 | SHOW_STR | |
8486 | BGP_STR | |
8487 | "Address family\n" | |
8488 | "Display routes matching the communities\n" | |
8489 | "community number\n" | |
8490 | "Do not send outside local AS (well-known community)\n" | |
8491 | "Do not advertise to any peer (well-known community)\n" | |
8492 | "Do not export to next AS (well-known community)\n" | |
8493 | "community number\n" | |
8494 | "Do not send outside local AS (well-known community)\n" | |
8495 | "Do not advertise to any peer (well-known community)\n" | |
8496 | "Do not export to next AS (well-known community)\n" | |
8497 | "Exact match of the communities") | |
8498 | ||
8499 | ALIAS (show_bgp_community_exact, | |
8500 | show_bgp_community3_exact_cmd, | |
8501 | "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", | |
8502 | SHOW_STR | |
8503 | BGP_STR | |
8504 | "Display routes matching the communities\n" | |
8505 | "community number\n" | |
8506 | "Do not send outside local AS (well-known community)\n" | |
8507 | "Do not advertise to any peer (well-known community)\n" | |
8508 | "Do not export to next AS (well-known community)\n" | |
8509 | "community number\n" | |
8510 | "Do not send outside local AS (well-known community)\n" | |
8511 | "Do not advertise to any peer (well-known community)\n" | |
8512 | "Do not export to next AS (well-known community)\n" | |
8513 | "community number\n" | |
8514 | "Do not send outside local AS (well-known community)\n" | |
8515 | "Do not advertise to any peer (well-known community)\n" | |
8516 | "Do not export to next AS (well-known community)\n" | |
8517 | "Exact match of the communities") | |
8518 | ||
8519 | ALIAS (show_bgp_community_exact, | |
8520 | show_bgp_ipv6_community3_exact_cmd, | |
8521 | "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", | |
8522 | SHOW_STR | |
8523 | BGP_STR | |
8524 | "Address family\n" | |
8525 | "Display routes matching the communities\n" | |
8526 | "community number\n" | |
8527 | "Do not send outside local AS (well-known community)\n" | |
8528 | "Do not advertise to any peer (well-known community)\n" | |
8529 | "Do not export to next AS (well-known community)\n" | |
8530 | "community number\n" | |
8531 | "Do not send outside local AS (well-known community)\n" | |
8532 | "Do not advertise to any peer (well-known community)\n" | |
8533 | "Do not export to next AS (well-known community)\n" | |
8534 | "community number\n" | |
8535 | "Do not send outside local AS (well-known community)\n" | |
8536 | "Do not advertise to any peer (well-known community)\n" | |
8537 | "Do not export to next AS (well-known community)\n" | |
8538 | "Exact match of the communities") | |
8539 | ||
8540 | ALIAS (show_bgp_community_exact, | |
8541 | show_bgp_community4_exact_cmd, | |
8542 | "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", | |
8543 | SHOW_STR | |
8544 | BGP_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 | "community number\n" | |
8551 | "Do not send outside local AS (well-known community)\n" | |
8552 | "Do not advertise to any peer (well-known community)\n" | |
8553 | "Do not export to next AS (well-known community)\n" | |
8554 | "community number\n" | |
8555 | "Do not send outside local AS (well-known community)\n" | |
8556 | "Do not advertise to any peer (well-known community)\n" | |
8557 | "Do not export to next AS (well-known community)\n" | |
8558 | "community number\n" | |
8559 | "Do not send outside local AS (well-known community)\n" | |
8560 | "Do not advertise to any peer (well-known community)\n" | |
8561 | "Do not export to next AS (well-known community)\n" | |
8562 | "Exact match of the communities") | |
8563 | ||
8564 | ALIAS (show_bgp_community_exact, | |
8565 | show_bgp_ipv6_community4_exact_cmd, | |
8566 | "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", | |
8567 | SHOW_STR | |
8568 | BGP_STR | |
8569 | "Address family\n" | |
8570 | "Display routes matching the communities\n" | |
8571 | "community number\n" | |
8572 | "Do not send outside local AS (well-known community)\n" | |
8573 | "Do not advertise to any peer (well-known community)\n" | |
8574 | "Do not export to next AS (well-known community)\n" | |
8575 | "community number\n" | |
8576 | "Do not send outside local AS (well-known community)\n" | |
8577 | "Do not advertise to any peer (well-known community)\n" | |
8578 | "Do not export to next AS (well-known community)\n" | |
8579 | "community number\n" | |
8580 | "Do not send outside local AS (well-known community)\n" | |
8581 | "Do not advertise to any peer (well-known community)\n" | |
8582 | "Do not export to next AS (well-known community)\n" | |
8583 | "community number\n" | |
8584 | "Do not send outside local AS (well-known community)\n" | |
8585 | "Do not advertise to any peer (well-known community)\n" | |
8586 | "Do not export to next AS (well-known community)\n" | |
8587 | "Exact match of the communities") | |
8588 | ||
8589 | /* old command */ | |
8590 | DEFUN (show_ipv6_bgp_community_exact, | |
8591 | show_ipv6_bgp_community_exact_cmd, | |
8592 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8593 | SHOW_STR | |
8594 | IPV6_STR | |
8595 | BGP_STR | |
8596 | "Display routes matching the communities\n" | |
8597 | "community number\n" | |
8598 | "Do not send outside local AS (well-known community)\n" | |
8599 | "Do not advertise to any peer (well-known community)\n" | |
8600 | "Do not export to next AS (well-known community)\n" | |
8601 | "Exact match of the communities") | |
8602 | { | |
95cbbd2a | 8603 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8604 | } |
8605 | ||
8606 | /* old command */ | |
8607 | ALIAS (show_ipv6_bgp_community_exact, | |
8608 | show_ipv6_bgp_community2_exact_cmd, | |
8609 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8610 | SHOW_STR | |
8611 | IPV6_STR | |
8612 | BGP_STR | |
8613 | "Display routes matching the communities\n" | |
8614 | "community number\n" | |
8615 | "Do not send outside local AS (well-known community)\n" | |
8616 | "Do not advertise to any peer (well-known community)\n" | |
8617 | "Do not export to next AS (well-known community)\n" | |
8618 | "community number\n" | |
8619 | "Do not send outside local AS (well-known community)\n" | |
8620 | "Do not advertise to any peer (well-known community)\n" | |
8621 | "Do not export to next AS (well-known community)\n" | |
8622 | "Exact match of the communities") | |
8623 | ||
8624 | /* old command */ | |
8625 | ALIAS (show_ipv6_bgp_community_exact, | |
8626 | show_ipv6_bgp_community3_exact_cmd, | |
8627 | "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", | |
8628 | SHOW_STR | |
8629 | IPV6_STR | |
8630 | BGP_STR | |
8631 | "Display routes matching the communities\n" | |
8632 | "community number\n" | |
8633 | "Do not send outside local AS (well-known community)\n" | |
8634 | "Do not advertise to any peer (well-known community)\n" | |
8635 | "Do not export to next AS (well-known community)\n" | |
8636 | "community number\n" | |
8637 | "Do not send outside local AS (well-known community)\n" | |
8638 | "Do not advertise to any peer (well-known community)\n" | |
8639 | "Do not export to next AS (well-known community)\n" | |
8640 | "community number\n" | |
8641 | "Do not send outside local AS (well-known community)\n" | |
8642 | "Do not advertise to any peer (well-known community)\n" | |
8643 | "Do not export to next AS (well-known community)\n" | |
8644 | "Exact match of the communities") | |
8645 | ||
8646 | /* old command */ | |
8647 | ALIAS (show_ipv6_bgp_community_exact, | |
8648 | show_ipv6_bgp_community4_exact_cmd, | |
8649 | "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", | |
8650 | SHOW_STR | |
8651 | IPV6_STR | |
8652 | BGP_STR | |
8653 | "Display routes matching the communities\n" | |
8654 | "community number\n" | |
8655 | "Do not send outside local AS (well-known community)\n" | |
8656 | "Do not advertise to any peer (well-known community)\n" | |
8657 | "Do not export to next AS (well-known community)\n" | |
8658 | "community number\n" | |
8659 | "Do not send outside local AS (well-known community)\n" | |
8660 | "Do not advertise to any peer (well-known community)\n" | |
8661 | "Do not export to next AS (well-known community)\n" | |
8662 | "community number\n" | |
8663 | "Do not send outside local AS (well-known community)\n" | |
8664 | "Do not advertise to any peer (well-known community)\n" | |
8665 | "Do not export to next AS (well-known community)\n" | |
8666 | "community number\n" | |
8667 | "Do not send outside local AS (well-known community)\n" | |
8668 | "Do not advertise to any peer (well-known community)\n" | |
8669 | "Do not export to next AS (well-known community)\n" | |
8670 | "Exact match of the communities") | |
8671 | ||
8672 | /* old command */ | |
8673 | DEFUN (show_ipv6_mbgp_community, | |
8674 | show_ipv6_mbgp_community_cmd, | |
8675 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8676 | SHOW_STR | |
8677 | IPV6_STR | |
8678 | MBGP_STR | |
8679 | "Display routes matching the communities\n" | |
8680 | "community number\n" | |
8681 | "Do not send outside local AS (well-known community)\n" | |
8682 | "Do not advertise to any peer (well-known community)\n" | |
8683 | "Do not export to next AS (well-known community)\n") | |
8684 | { | |
95cbbd2a | 8685 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 8686 | } |
8687 | ||
8688 | /* old command */ | |
8689 | ALIAS (show_ipv6_mbgp_community, | |
8690 | show_ipv6_mbgp_community2_cmd, | |
8691 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8692 | SHOW_STR | |
8693 | IPV6_STR | |
8694 | MBGP_STR | |
8695 | "Display routes matching the communities\n" | |
8696 | "community number\n" | |
8697 | "Do not send outside local AS (well-known community)\n" | |
8698 | "Do not advertise to any peer (well-known community)\n" | |
8699 | "Do not export to next AS (well-known community)\n" | |
8700 | "community number\n" | |
8701 | "Do not send outside local AS (well-known community)\n" | |
8702 | "Do not advertise to any peer (well-known community)\n" | |
8703 | "Do not export to next AS (well-known community)\n") | |
8704 | ||
8705 | /* old command */ | |
8706 | ALIAS (show_ipv6_mbgp_community, | |
8707 | show_ipv6_mbgp_community3_cmd, | |
8708 | "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)", | |
8709 | SHOW_STR | |
8710 | IPV6_STR | |
8711 | MBGP_STR | |
8712 | "Display routes matching the communities\n" | |
8713 | "community number\n" | |
8714 | "Do not send outside local AS (well-known community)\n" | |
8715 | "Do not advertise to any peer (well-known community)\n" | |
8716 | "Do not export to next AS (well-known community)\n" | |
8717 | "community number\n" | |
8718 | "Do not send outside local AS (well-known community)\n" | |
8719 | "Do not advertise to any peer (well-known community)\n" | |
8720 | "Do not export to next AS (well-known community)\n" | |
8721 | "community number\n" | |
8722 | "Do not send outside local AS (well-known community)\n" | |
8723 | "Do not advertise to any peer (well-known community)\n" | |
8724 | "Do not export to next AS (well-known community)\n") | |
8725 | ||
8726 | /* old command */ | |
8727 | ALIAS (show_ipv6_mbgp_community, | |
8728 | show_ipv6_mbgp_community4_cmd, | |
8729 | "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)", | |
8730 | SHOW_STR | |
8731 | IPV6_STR | |
8732 | MBGP_STR | |
8733 | "Display routes matching the communities\n" | |
8734 | "community number\n" | |
8735 | "Do not send outside local AS (well-known community)\n" | |
8736 | "Do not advertise to any peer (well-known community)\n" | |
8737 | "Do not export to next AS (well-known community)\n" | |
8738 | "community number\n" | |
8739 | "Do not send outside local AS (well-known community)\n" | |
8740 | "Do not advertise to any peer (well-known community)\n" | |
8741 | "Do not export to next AS (well-known community)\n" | |
8742 | "community number\n" | |
8743 | "Do not send outside local AS (well-known community)\n" | |
8744 | "Do not advertise to any peer (well-known community)\n" | |
8745 | "Do not export to next AS (well-known community)\n" | |
8746 | "community number\n" | |
8747 | "Do not send outside local AS (well-known community)\n" | |
8748 | "Do not advertise to any peer (well-known community)\n" | |
8749 | "Do not export to next AS (well-known community)\n") | |
8750 | ||
8751 | /* old command */ | |
8752 | DEFUN (show_ipv6_mbgp_community_exact, | |
8753 | show_ipv6_mbgp_community_exact_cmd, | |
8754 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8755 | SHOW_STR | |
8756 | IPV6_STR | |
8757 | MBGP_STR | |
8758 | "Display routes matching the communities\n" | |
8759 | "community number\n" | |
8760 | "Do not send outside local AS (well-known community)\n" | |
8761 | "Do not advertise to any peer (well-known community)\n" | |
8762 | "Do not export to next AS (well-known community)\n" | |
8763 | "Exact match of the communities") | |
8764 | { | |
95cbbd2a | 8765 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 8766 | } |
8767 | ||
8768 | /* old command */ | |
8769 | ALIAS (show_ipv6_mbgp_community_exact, | |
8770 | show_ipv6_mbgp_community2_exact_cmd, | |
8771 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8772 | SHOW_STR | |
8773 | IPV6_STR | |
8774 | MBGP_STR | |
8775 | "Display routes matching the communities\n" | |
8776 | "community number\n" | |
8777 | "Do not send outside local AS (well-known community)\n" | |
8778 | "Do not advertise to any peer (well-known community)\n" | |
8779 | "Do not export to next AS (well-known community)\n" | |
8780 | "community number\n" | |
8781 | "Do not send outside local AS (well-known community)\n" | |
8782 | "Do not advertise to any peer (well-known community)\n" | |
8783 | "Do not export to next AS (well-known community)\n" | |
8784 | "Exact match of the communities") | |
8785 | ||
8786 | /* old command */ | |
8787 | ALIAS (show_ipv6_mbgp_community_exact, | |
8788 | show_ipv6_mbgp_community3_exact_cmd, | |
8789 | "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", | |
8790 | SHOW_STR | |
8791 | IPV6_STR | |
8792 | MBGP_STR | |
8793 | "Display routes matching the communities\n" | |
8794 | "community number\n" | |
8795 | "Do not send outside local AS (well-known community)\n" | |
8796 | "Do not advertise to any peer (well-known community)\n" | |
8797 | "Do not export to next AS (well-known community)\n" | |
8798 | "community number\n" | |
8799 | "Do not send outside local AS (well-known community)\n" | |
8800 | "Do not advertise to any peer (well-known community)\n" | |
8801 | "Do not export to next AS (well-known community)\n" | |
8802 | "community number\n" | |
8803 | "Do not send outside local AS (well-known community)\n" | |
8804 | "Do not advertise to any peer (well-known community)\n" | |
8805 | "Do not export to next AS (well-known community)\n" | |
8806 | "Exact match of the communities") | |
8807 | ||
8808 | /* old command */ | |
8809 | ALIAS (show_ipv6_mbgp_community_exact, | |
8810 | show_ipv6_mbgp_community4_exact_cmd, | |
8811 | "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", | |
8812 | SHOW_STR | |
8813 | IPV6_STR | |
8814 | MBGP_STR | |
8815 | "Display routes matching the communities\n" | |
8816 | "community number\n" | |
8817 | "Do not send outside local AS (well-known community)\n" | |
8818 | "Do not advertise to any peer (well-known community)\n" | |
8819 | "Do not export to next AS (well-known community)\n" | |
8820 | "community number\n" | |
8821 | "Do not send outside local AS (well-known community)\n" | |
8822 | "Do not advertise to any peer (well-known community)\n" | |
8823 | "Do not export to next AS (well-known community)\n" | |
8824 | "community number\n" | |
8825 | "Do not send outside local AS (well-known community)\n" | |
8826 | "Do not advertise to any peer (well-known community)\n" | |
8827 | "Do not export to next AS (well-known community)\n" | |
8828 | "community number\n" | |
8829 | "Do not send outside local AS (well-known community)\n" | |
8830 | "Do not advertise to any peer (well-known community)\n" | |
8831 | "Do not export to next AS (well-known community)\n" | |
8832 | "Exact match of the communities") | |
8833 | #endif /* HAVE_IPV6 */ | |
8834 | \f | |
94f2b392 | 8835 | static int |
fd79ac91 | 8836 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
4c9641ba | 8837 | afi_t afi, safi_t safi) |
718e3744 | 8838 | { |
8839 | struct community_list *list; | |
8840 | ||
fee6e4e4 | 8841 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 8842 | if (list == NULL) |
8843 | { | |
8844 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
8845 | VTY_NEWLINE); | |
8846 | return CMD_WARNING; | |
8847 | } | |
8848 | ||
5a646650 | 8849 | return bgp_show (vty, NULL, afi, safi, |
8850 | (exact ? bgp_show_type_community_list_exact : | |
8851 | bgp_show_type_community_list), list); | |
718e3744 | 8852 | } |
8853 | ||
8854 | DEFUN (show_ip_bgp_community_list, | |
8855 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 8856 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 8857 | SHOW_STR |
8858 | IP_STR | |
8859 | BGP_STR | |
8860 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8861 | "community-list number\n" |
718e3744 | 8862 | "community-list name\n") |
8863 | { | |
8864 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); | |
8865 | } | |
8866 | ||
8867 | DEFUN (show_ip_bgp_ipv4_community_list, | |
8868 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 8869 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 8870 | SHOW_STR |
8871 | IP_STR | |
8872 | BGP_STR | |
8873 | "Address family\n" | |
8874 | "Address Family modifier\n" | |
8875 | "Address Family modifier\n" | |
8876 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8877 | "community-list number\n" |
718e3744 | 8878 | "community-list name\n") |
8879 | { | |
8880 | if (strncmp (argv[0], "m", 1) == 0) | |
8881 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); | |
8882 | ||
8883 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); | |
8884 | } | |
8885 | ||
8886 | DEFUN (show_ip_bgp_community_list_exact, | |
8887 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8888 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8889 | SHOW_STR |
8890 | IP_STR | |
8891 | BGP_STR | |
8892 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8893 | "community-list number\n" |
718e3744 | 8894 | "community-list name\n" |
8895 | "Exact match of the communities\n") | |
8896 | { | |
8897 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); | |
8898 | } | |
8899 | ||
8900 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
8901 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 8902 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 8903 | SHOW_STR |
8904 | IP_STR | |
8905 | BGP_STR | |
8906 | "Address family\n" | |
8907 | "Address Family modifier\n" | |
8908 | "Address Family modifier\n" | |
8909 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8910 | "community-list number\n" |
718e3744 | 8911 | "community-list name\n" |
8912 | "Exact match of the communities\n") | |
8913 | { | |
8914 | if (strncmp (argv[0], "m", 1) == 0) | |
8915 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); | |
8916 | ||
8917 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); | |
8918 | } | |
8919 | ||
8920 | #ifdef HAVE_IPV6 | |
8921 | DEFUN (show_bgp_community_list, | |
8922 | show_bgp_community_list_cmd, | |
fee6e4e4 | 8923 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 8924 | SHOW_STR |
8925 | BGP_STR | |
8926 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8927 | "community-list number\n" |
718e3744 | 8928 | "community-list name\n") |
8929 | { | |
8930 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8931 | } | |
8932 | ||
8933 | ALIAS (show_bgp_community_list, | |
8934 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 8935 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 8936 | SHOW_STR |
8937 | BGP_STR | |
8938 | "Address family\n" | |
8939 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8940 | "community-list number\n" |
e8e1946e | 8941 | "community-list name\n") |
718e3744 | 8942 | |
8943 | /* old command */ | |
8944 | DEFUN (show_ipv6_bgp_community_list, | |
8945 | show_ipv6_bgp_community_list_cmd, | |
8946 | "show ipv6 bgp community-list WORD", | |
8947 | SHOW_STR | |
8948 | IPV6_STR | |
8949 | BGP_STR | |
8950 | "Display routes matching the community-list\n" | |
8951 | "community-list name\n") | |
8952 | { | |
8953 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8954 | } | |
8955 | ||
8956 | /* old command */ | |
8957 | DEFUN (show_ipv6_mbgp_community_list, | |
8958 | show_ipv6_mbgp_community_list_cmd, | |
8959 | "show ipv6 mbgp community-list WORD", | |
8960 | SHOW_STR | |
8961 | IPV6_STR | |
8962 | MBGP_STR | |
8963 | "Display routes matching the community-list\n" | |
8964 | "community-list name\n") | |
8965 | { | |
8966 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); | |
8967 | } | |
8968 | ||
8969 | DEFUN (show_bgp_community_list_exact, | |
8970 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8971 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8972 | SHOW_STR |
8973 | BGP_STR | |
8974 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8975 | "community-list number\n" |
718e3744 | 8976 | "community-list name\n" |
8977 | "Exact match of the communities\n") | |
8978 | { | |
8979 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8980 | } | |
8981 | ||
8982 | ALIAS (show_bgp_community_list_exact, | |
8983 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 8984 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 8985 | SHOW_STR |
8986 | BGP_STR | |
8987 | "Address family\n" | |
8988 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8989 | "community-list number\n" |
718e3744 | 8990 | "community-list name\n" |
8991 | "Exact match of the communities\n") | |
8992 | ||
8993 | /* old command */ | |
8994 | DEFUN (show_ipv6_bgp_community_list_exact, | |
8995 | show_ipv6_bgp_community_list_exact_cmd, | |
8996 | "show ipv6 bgp community-list WORD exact-match", | |
8997 | SHOW_STR | |
8998 | IPV6_STR | |
8999 | BGP_STR | |
9000 | "Display routes matching the community-list\n" | |
9001 | "community-list name\n" | |
9002 | "Exact match of the communities\n") | |
9003 | { | |
9004 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
9005 | } | |
9006 | ||
9007 | /* old command */ | |
9008 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
9009 | show_ipv6_mbgp_community_list_exact_cmd, | |
9010 | "show ipv6 mbgp community-list WORD exact-match", | |
9011 | SHOW_STR | |
9012 | IPV6_STR | |
9013 | MBGP_STR | |
9014 | "Display routes matching the community-list\n" | |
9015 | "community-list name\n" | |
9016 | "Exact match of the communities\n") | |
9017 | { | |
9018 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); | |
9019 | } | |
9020 | #endif /* HAVE_IPV6 */ | |
9021 | \f | |
94f2b392 | 9022 | static int |
fd79ac91 | 9023 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
718e3744 | 9024 | safi_t safi, enum bgp_show_type type) |
9025 | { | |
9026 | int ret; | |
9027 | struct prefix *p; | |
9028 | ||
9029 | p = prefix_new(); | |
9030 | ||
9031 | ret = str2prefix (prefix, p); | |
9032 | if (! ret) | |
9033 | { | |
9034 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
9035 | return CMD_WARNING; | |
9036 | } | |
9037 | ||
5a646650 | 9038 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
9039 | prefix_free(p); | |
9040 | return ret; | |
718e3744 | 9041 | } |
9042 | ||
9043 | DEFUN (show_ip_bgp_prefix_longer, | |
9044 | show_ip_bgp_prefix_longer_cmd, | |
9045 | "show ip bgp A.B.C.D/M longer-prefixes", | |
9046 | SHOW_STR | |
9047 | IP_STR | |
9048 | BGP_STR | |
9049 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
9050 | "Display route and more specific routes\n") | |
9051 | { | |
9052 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9053 | bgp_show_type_prefix_longer); | |
9054 | } | |
9055 | ||
9056 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
9057 | show_ip_bgp_flap_prefix_longer_cmd, | |
9058 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
9059 | SHOW_STR | |
9060 | IP_STR | |
9061 | BGP_STR | |
9062 | "Display flap statistics of routes\n" | |
9063 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
9064 | "Display route and more specific routes\n") | |
9065 | { | |
9066 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9067 | bgp_show_type_flap_prefix_longer); | |
9068 | } | |
9069 | ||
9070 | DEFUN (show_ip_bgp_ipv4_prefix_longer, | |
9071 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
9072 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
9073 | SHOW_STR | |
9074 | IP_STR | |
9075 | BGP_STR | |
9076 | "Address family\n" | |
9077 | "Address Family modifier\n" | |
9078 | "Address Family modifier\n" | |
9079 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
9080 | "Display route and more specific routes\n") | |
9081 | { | |
9082 | if (strncmp (argv[0], "m", 1) == 0) | |
9083 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
9084 | bgp_show_type_prefix_longer); | |
9085 | ||
9086 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
9087 | bgp_show_type_prefix_longer); | |
9088 | } | |
9089 | ||
9090 | DEFUN (show_ip_bgp_flap_address, | |
9091 | show_ip_bgp_flap_address_cmd, | |
9092 | "show ip bgp flap-statistics A.B.C.D", | |
9093 | SHOW_STR | |
9094 | IP_STR | |
9095 | BGP_STR | |
9096 | "Display flap statistics of routes\n" | |
9097 | "Network in the BGP routing table to display\n") | |
9098 | { | |
9099 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9100 | bgp_show_type_flap_address); | |
9101 | } | |
9102 | ||
9103 | DEFUN (show_ip_bgp_flap_prefix, | |
9104 | show_ip_bgp_flap_prefix_cmd, | |
9105 | "show ip bgp flap-statistics A.B.C.D/M", | |
9106 | SHOW_STR | |
9107 | IP_STR | |
9108 | BGP_STR | |
9109 | "Display flap statistics of routes\n" | |
9110 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
9111 | { | |
9112 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9113 | bgp_show_type_flap_prefix); | |
9114 | } | |
9115 | #ifdef HAVE_IPV6 | |
9116 | DEFUN (show_bgp_prefix_longer, | |
9117 | show_bgp_prefix_longer_cmd, | |
9118 | "show bgp X:X::X:X/M longer-prefixes", | |
9119 | SHOW_STR | |
9120 | BGP_STR | |
9121 | "IPv6 prefix <network>/<length>\n" | |
9122 | "Display route and more specific routes\n") | |
9123 | { | |
9124 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
9125 | bgp_show_type_prefix_longer); | |
9126 | } | |
9127 | ||
9128 | ALIAS (show_bgp_prefix_longer, | |
9129 | show_bgp_ipv6_prefix_longer_cmd, | |
9130 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
9131 | SHOW_STR | |
9132 | BGP_STR | |
9133 | "Address family\n" | |
9134 | "IPv6 prefix <network>/<length>\n" | |
9135 | "Display route and more specific routes\n") | |
9136 | ||
9137 | /* old command */ | |
9138 | DEFUN (show_ipv6_bgp_prefix_longer, | |
9139 | show_ipv6_bgp_prefix_longer_cmd, | |
9140 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
9141 | SHOW_STR | |
9142 | IPV6_STR | |
9143 | BGP_STR | |
9144 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
9145 | "Display route and more specific routes\n") | |
9146 | { | |
9147 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
9148 | bgp_show_type_prefix_longer); | |
9149 | } | |
9150 | ||
9151 | /* old command */ | |
9152 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
9153 | show_ipv6_mbgp_prefix_longer_cmd, | |
9154 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
9155 | SHOW_STR | |
9156 | IPV6_STR | |
9157 | MBGP_STR | |
9158 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
9159 | "Display route and more specific routes\n") | |
9160 | { | |
9161 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
9162 | bgp_show_type_prefix_longer); | |
9163 | } | |
9164 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 9165 | |
94f2b392 | 9166 | static struct peer * |
fd79ac91 | 9167 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
9168 | const char *ip_str) | |
bb46e94f | 9169 | { |
9170 | int ret; | |
9171 | struct bgp *bgp; | |
9172 | struct peer *peer; | |
9173 | union sockunion su; | |
9174 | ||
9175 | /* BGP structure lookup. */ | |
9176 | if (view_name) | |
9177 | { | |
9178 | bgp = bgp_lookup_by_name (view_name); | |
9179 | if (! bgp) | |
9180 | { | |
9181 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
9182 | return NULL; | |
9183 | } | |
9184 | } | |
5228ad27 | 9185 | else |
bb46e94f | 9186 | { |
9187 | bgp = bgp_get_default (); | |
9188 | if (! bgp) | |
9189 | { | |
9190 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
9191 | return NULL; | |
9192 | } | |
9193 | } | |
9194 | ||
9195 | /* Get peer sockunion. */ | |
9196 | ret = str2sockunion (ip_str, &su); | |
9197 | if (ret < 0) | |
9198 | { | |
9199 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); | |
9200 | return NULL; | |
9201 | } | |
9202 | ||
9203 | /* Peer structure lookup. */ | |
9204 | peer = peer_lookup (bgp, &su); | |
9205 | if (! peer) | |
9206 | { | |
9207 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
9208 | return NULL; | |
9209 | } | |
9210 | ||
9211 | return peer; | |
9212 | } | |
2815e61f PJ |
9213 | \f |
9214 | enum bgp_stats | |
9215 | { | |
9216 | BGP_STATS_MAXBITLEN = 0, | |
9217 | BGP_STATS_RIB, | |
9218 | BGP_STATS_PREFIXES, | |
9219 | BGP_STATS_TOTPLEN, | |
9220 | BGP_STATS_UNAGGREGATEABLE, | |
9221 | BGP_STATS_MAX_AGGREGATEABLE, | |
9222 | BGP_STATS_AGGREGATES, | |
9223 | BGP_STATS_SPACE, | |
9224 | BGP_STATS_ASPATH_COUNT, | |
9225 | BGP_STATS_ASPATH_MAXHOPS, | |
9226 | BGP_STATS_ASPATH_TOTHOPS, | |
9227 | BGP_STATS_ASPATH_MAXSIZE, | |
9228 | BGP_STATS_ASPATH_TOTSIZE, | |
9229 | BGP_STATS_ASN_HIGHEST, | |
9230 | BGP_STATS_MAX, | |
9231 | }; | |
9232 | ||
9233 | static const char *table_stats_strs[] = | |
9234 | { | |
9235 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
9236 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
9237 | [BGP_STATS_RIB] = "Total Advertisements", | |
9238 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
9239 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
9240 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
9241 | [BGP_STATS_SPACE] = "Address space advertised", | |
9242 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
9243 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
9244 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
9245 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
9246 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
9247 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
9248 | [BGP_STATS_MAX] = NULL, | |
9249 | }; | |
9250 | ||
9251 | struct bgp_table_stats | |
9252 | { | |
9253 | struct bgp_table *table; | |
9254 | unsigned long long counts[BGP_STATS_MAX]; | |
9255 | }; | |
9256 | ||
9257 | #if 0 | |
9258 | #define TALLY_SIGFIG 100000 | |
9259 | static unsigned long | |
9260 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
9261 | { | |
9262 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
9263 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
9264 | unsigned long ret = newtot / count; | |
9265 | ||
9266 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
9267 | return ret + 1; | |
9268 | else | |
9269 | return ret; | |
9270 | } | |
9271 | #endif | |
9272 | ||
9273 | static int | |
9274 | bgp_table_stats_walker (struct thread *t) | |
9275 | { | |
9276 | struct bgp_node *rn; | |
9277 | struct bgp_node *top; | |
9278 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
9279 | unsigned int space = 0; | |
9280 | ||
53d9f67a PJ |
9281 | if (!(top = bgp_table_top (ts->table))) |
9282 | return 0; | |
2815e61f PJ |
9283 | |
9284 | switch (top->p.family) | |
9285 | { | |
9286 | case AF_INET: | |
9287 | space = IPV4_MAX_BITLEN; | |
9288 | break; | |
9289 | case AF_INET6: | |
9290 | space = IPV6_MAX_BITLEN; | |
9291 | break; | |
9292 | } | |
9293 | ||
9294 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
9295 | ||
9296 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
9297 | { | |
9298 | struct bgp_info *ri; | |
9299 | struct bgp_node *prn = rn->parent; | |
9300 | unsigned int rinum = 0; | |
9301 | ||
9302 | if (rn == top) | |
9303 | continue; | |
9304 | ||
9305 | if (!rn->info) | |
9306 | continue; | |
9307 | ||
9308 | ts->counts[BGP_STATS_PREFIXES]++; | |
9309 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
9310 | ||
9311 | #if 0 | |
9312 | ts->counts[BGP_STATS_AVGPLEN] | |
9313 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
9314 | ts->counts[BGP_STATS_AVGPLEN], | |
9315 | rn->p.prefixlen); | |
9316 | #endif | |
9317 | ||
9318 | /* check if the prefix is included by any other announcements */ | |
9319 | while (prn && !prn->info) | |
9320 | prn = prn->parent; | |
9321 | ||
9322 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
9323 | { |
9324 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
9325 | /* announced address space */ | |
9326 | if (space) | |
9327 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
9328 | } | |
2815e61f PJ |
9329 | else if (prn->info) |
9330 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
9331 | ||
2815e61f PJ |
9332 | for (ri = rn->info; ri; ri = ri->next) |
9333 | { | |
9334 | rinum++; | |
9335 | ts->counts[BGP_STATS_RIB]++; | |
9336 | ||
9337 | if (ri->attr && | |
9338 | (CHECK_FLAG (ri->attr->flag, | |
9339 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
9340 | ts->counts[BGP_STATS_AGGREGATES]++; | |
9341 | ||
9342 | /* as-path stats */ | |
9343 | if (ri->attr && ri->attr->aspath) | |
9344 | { | |
9345 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
9346 | unsigned int size = aspath_size (ri->attr->aspath); | |
9347 | as_t highest = aspath_highest (ri->attr->aspath); | |
9348 | ||
9349 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
9350 | ||
9351 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
9352 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
9353 | ||
9354 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
9355 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
9356 | ||
9357 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
9358 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
9359 | #if 0 | |
9360 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
9361 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9362 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
9363 | hops); | |
9364 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
9365 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9366 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
9367 | size); | |
9368 | #endif | |
9369 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
9370 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
9371 | } | |
9372 | } | |
9373 | } | |
9374 | return 0; | |
9375 | } | |
9376 | ||
9377 | static int | |
9378 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
9379 | { | |
9380 | struct bgp_table_stats ts; | |
9381 | unsigned int i; | |
9382 | ||
9383 | if (!bgp->rib[afi][safi]) | |
9384 | { | |
9385 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); | |
9386 | return CMD_WARNING; | |
9387 | } | |
9388 | ||
9389 | memset (&ts, 0, sizeof (ts)); | |
9390 | ts.table = bgp->rib[afi][safi]; | |
9391 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); | |
bb46e94f | 9392 | |
2815e61f PJ |
9393 | vty_out (vty, "BGP %s RIB statistics%s%s", |
9394 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
9395 | ||
9396 | for (i = 0; i < BGP_STATS_MAX; i++) | |
9397 | { | |
9398 | if (!table_stats_strs[i]) | |
9399 | continue; | |
9400 | ||
9401 | switch (i) | |
9402 | { | |
9403 | #if 0 | |
9404 | case BGP_STATS_ASPATH_AVGHOPS: | |
9405 | case BGP_STATS_ASPATH_AVGSIZE: | |
9406 | case BGP_STATS_AVGPLEN: | |
9407 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9408 | vty_out (vty, "%12.2f", | |
9409 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
9410 | break; | |
9411 | #endif | |
9412 | case BGP_STATS_ASPATH_TOTHOPS: | |
9413 | case BGP_STATS_ASPATH_TOTSIZE: | |
9414 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9415 | vty_out (vty, "%12.2f", | |
9416 | ts.counts[i] ? | |
9417 | (float)ts.counts[i] / | |
9418 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
9419 | : 0); | |
9420 | break; | |
9421 | case BGP_STATS_TOTPLEN: | |
9422 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9423 | vty_out (vty, "%12.2f", | |
9424 | ts.counts[i] ? | |
9425 | (float)ts.counts[i] / | |
9426 | (float)ts.counts[BGP_STATS_PREFIXES] | |
9427 | : 0); | |
9428 | break; | |
9429 | case BGP_STATS_SPACE: | |
9430 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9431 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
9432 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
9433 | break; | |
30a2231a | 9434 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
9435 | vty_out (vty, "%12.2f%s", |
9436 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 9437 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
9438 | VTY_NEWLINE); |
9439 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
9440 | vty_out (vty, "%12.2f%s", | |
9441 | (float)ts.counts[BGP_STATS_SPACE] / | |
9442 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
9443 | VTY_NEWLINE); | |
9444 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
9445 | break; | |
9446 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
9447 | vty_out (vty, "%12.2f", | |
9448 | (float)ts.counts[BGP_STATS_SPACE] / | |
9449 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
9450 | break; | |
9451 | default: | |
9452 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9453 | vty_out (vty, "%12llu", ts.counts[i]); | |
9454 | } | |
9455 | ||
9456 | vty_out (vty, "%s", VTY_NEWLINE); | |
9457 | } | |
9458 | return CMD_SUCCESS; | |
9459 | } | |
9460 | ||
9461 | static int | |
9462 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
9463 | const char *afi_str, const char *safi_str) | |
9464 | { | |
9465 | struct bgp *bgp; | |
9466 | afi_t afi; | |
9467 | safi_t safi; | |
9468 | ||
9469 | if (name) | |
9470 | bgp = bgp_lookup_by_name (name); | |
9471 | else | |
9472 | bgp = bgp_get_default (); | |
9473 | ||
9474 | if (!bgp) | |
9475 | { | |
9476 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9477 | return CMD_WARNING; | |
9478 | } | |
9479 | if (strncmp (afi_str, "ipv", 3) == 0) | |
9480 | { | |
9481 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
9482 | afi = AFI_IP; | |
9483 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
9484 | afi = AFI_IP6; | |
9485 | else | |
9486 | { | |
9487 | vty_out (vty, "%% Invalid address family %s%s", | |
9488 | afi_str, VTY_NEWLINE); | |
9489 | return CMD_WARNING; | |
9490 | } | |
9491 | if (strncmp (safi_str, "m", 1) == 0) | |
9492 | safi = SAFI_MULTICAST; | |
9493 | else if (strncmp (safi_str, "u", 1) == 0) | |
9494 | safi = SAFI_UNICAST; | |
42e6d745 DO |
9495 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
9496 | safi = SAFI_MPLS_LABELED_VPN; | |
2815e61f PJ |
9497 | else |
9498 | { | |
9499 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
9500 | safi_str, VTY_NEWLINE); | |
9501 | return CMD_WARNING; | |
9502 | } | |
9503 | } | |
9504 | else | |
9505 | { | |
9506 | vty_out (vty, "%% Invalid address family %s%s", | |
9507 | afi_str, VTY_NEWLINE); | |
9508 | return CMD_WARNING; | |
9509 | } | |
9510 | ||
2815e61f PJ |
9511 | return bgp_table_stats (vty, bgp, afi, safi); |
9512 | } | |
9513 | ||
9514 | DEFUN (show_bgp_statistics, | |
9515 | show_bgp_statistics_cmd, | |
9516 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", | |
9517 | SHOW_STR | |
9518 | BGP_STR | |
9519 | "Address family\n" | |
9520 | "Address family\n" | |
9521 | "Address Family modifier\n" | |
9522 | "Address Family modifier\n" | |
9523 | "BGP RIB advertisement statistics\n") | |
9524 | { | |
9525 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9526 | } | |
9527 | ||
9528 | ALIAS (show_bgp_statistics, | |
9529 | show_bgp_statistics_vpnv4_cmd, | |
9530 | "show bgp (ipv4) (vpnv4) statistics", | |
9531 | SHOW_STR | |
9532 | BGP_STR | |
9533 | "Address family\n" | |
9534 | "Address Family modifier\n" | |
9535 | "BGP RIB advertisement statistics\n") | |
9536 | ||
9537 | DEFUN (show_bgp_statistics_view, | |
9538 | show_bgp_statistics_view_cmd, | |
9539 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", | |
9540 | SHOW_STR | |
9541 | BGP_STR | |
9542 | "BGP view\n" | |
9543 | "Address family\n" | |
9544 | "Address family\n" | |
9545 | "Address Family modifier\n" | |
9546 | "Address Family modifier\n" | |
9547 | "BGP RIB advertisement statistics\n") | |
9548 | { | |
9549 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9550 | } | |
9551 | ||
9552 | ALIAS (show_bgp_statistics_view, | |
9553 | show_bgp_statistics_view_vpnv4_cmd, | |
9554 | "show bgp view WORD (ipv4) (vpnv4) statistics", | |
9555 | SHOW_STR | |
9556 | BGP_STR | |
9557 | "BGP view\n" | |
9558 | "Address family\n" | |
9559 | "Address Family modifier\n" | |
9560 | "BGP RIB advertisement statistics\n") | |
9561 | \f | |
ff7924f6 PJ |
9562 | enum bgp_pcounts |
9563 | { | |
9564 | PCOUNT_ADJ_IN = 0, | |
9565 | PCOUNT_DAMPED, | |
9566 | PCOUNT_REMOVED, | |
9567 | PCOUNT_HISTORY, | |
9568 | PCOUNT_STALE, | |
9569 | PCOUNT_VALID, | |
9570 | PCOUNT_ALL, | |
9571 | PCOUNT_COUNTED, | |
9572 | PCOUNT_PFCNT, /* the figure we display to users */ | |
9573 | PCOUNT_MAX, | |
9574 | }; | |
9575 | ||
9576 | static const char *pcount_strs[] = | |
9577 | { | |
9578 | [PCOUNT_ADJ_IN] = "Adj-in", | |
9579 | [PCOUNT_DAMPED] = "Damped", | |
9580 | [PCOUNT_REMOVED] = "Removed", | |
9581 | [PCOUNT_HISTORY] = "History", | |
9582 | [PCOUNT_STALE] = "Stale", | |
9583 | [PCOUNT_VALID] = "Valid", | |
9584 | [PCOUNT_ALL] = "All RIB", | |
9585 | [PCOUNT_COUNTED] = "PfxCt counted", | |
9586 | [PCOUNT_PFCNT] = "Useable", | |
9587 | [PCOUNT_MAX] = NULL, | |
9588 | }; | |
9589 | ||
2815e61f PJ |
9590 | struct peer_pcounts |
9591 | { | |
9592 | unsigned int count[PCOUNT_MAX]; | |
9593 | const struct peer *peer; | |
9594 | const struct bgp_table *table; | |
9595 | }; | |
9596 | ||
ff7924f6 | 9597 | static int |
2815e61f | 9598 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
9599 | { |
9600 | struct bgp_node *rn; | |
2815e61f PJ |
9601 | struct peer_pcounts *pc = THREAD_ARG (t); |
9602 | const struct peer *peer = pc->peer; | |
ff7924f6 | 9603 | |
2815e61f | 9604 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
9605 | { |
9606 | struct bgp_adj_in *ain; | |
2815e61f | 9607 | struct bgp_info *ri; |
ff7924f6 PJ |
9608 | |
9609 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9610 | if (ain->peer == peer) | |
2815e61f | 9611 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 9612 | |
ff7924f6 PJ |
9613 | for (ri = rn->info; ri; ri = ri->next) |
9614 | { | |
9615 | char buf[SU_ADDRSTRLEN]; | |
9616 | ||
9617 | if (ri->peer != peer) | |
9618 | continue; | |
9619 | ||
2815e61f | 9620 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
9621 | |
9622 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 9623 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 9624 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 9625 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 9626 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 9627 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 9628 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 9629 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 9630 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 9631 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 9632 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 9633 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
9634 | |
9635 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
9636 | { | |
2815e61f | 9637 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 9638 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9639 | plog_warn (peer->log, |
9640 | "%s [pcount] %s/%d is counted but flags 0x%x", | |
9641 | peer->host, | |
9642 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9643 | buf, SU_ADDRSTRLEN), | |
9644 | rn->p.prefixlen, | |
9645 | ri->flags); | |
9646 | } | |
9647 | else | |
9648 | { | |
1a392d46 | 9649 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9650 | plog_warn (peer->log, |
9651 | "%s [pcount] %s/%d not counted but flags 0x%x", | |
9652 | peer->host, | |
9653 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9654 | buf, SU_ADDRSTRLEN), | |
9655 | rn->p.prefixlen, | |
9656 | ri->flags); | |
9657 | } | |
9658 | } | |
9659 | } | |
2815e61f PJ |
9660 | return 0; |
9661 | } | |
ff7924f6 | 9662 | |
2815e61f PJ |
9663 | static int |
9664 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) | |
9665 | { | |
9666 | struct peer_pcounts pcounts = { .peer = peer }; | |
9667 | unsigned int i; | |
9668 | ||
9669 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
9670 | || !peer->bgp->rib[afi][safi]) | |
9671 | { | |
9672 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9673 | return CMD_WARNING; | |
9674 | } | |
9675 | ||
9676 | memset (&pcounts, 0, sizeof(pcounts)); | |
9677 | pcounts.peer = peer; | |
9678 | pcounts.table = peer->bgp->rib[afi][safi]; | |
9679 | ||
9680 | /* in-place call via thread subsystem so as to record execution time | |
9681 | * stats for the thread-walk (i.e. ensure this can't be blamed on | |
9682 | * on just vty_read()). | |
9683 | */ | |
9684 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); | |
9685 | ||
ff7924f6 PJ |
9686 | vty_out (vty, "Prefix counts for %s, %s%s", |
9687 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
9688 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); | |
9689 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
9690 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
9691 | ||
9692 | for (i = 0; i < PCOUNT_MAX; i++) | |
2815e61f PJ |
9693 | vty_out (vty, "%20s: %-10d%s", |
9694 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
ff7924f6 | 9695 | |
2815e61f | 9696 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
ff7924f6 PJ |
9697 | { |
9698 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
9699 | peer->host, VTY_NEWLINE); | |
9700 | vty_out (vty, "Please report this bug, with the above command output%s", | |
9701 | VTY_NEWLINE); | |
9702 | } | |
9703 | ||
9704 | return CMD_SUCCESS; | |
9705 | } | |
9706 | ||
9707 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
9708 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
9709 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9710 | SHOW_STR | |
9711 | IP_STR | |
9712 | BGP_STR | |
9713 | "Detailed information on TCP and BGP neighbor connections\n" | |
9714 | "Neighbor to display information about\n" | |
9715 | "Neighbor to display information about\n" | |
9716 | "Display detailed prefix count information\n") | |
9717 | { | |
9718 | struct peer *peer; | |
9719 | ||
9720 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9721 | if (! peer) | |
9722 | return CMD_WARNING; | |
9723 | ||
9724 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9725 | } | |
9726 | ||
9727 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, | |
9728 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
9729 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9730 | SHOW_STR | |
9731 | BGP_STR | |
9732 | "Address family\n" | |
9733 | "Detailed information on TCP and BGP neighbor connections\n" | |
9734 | "Neighbor to display information about\n" | |
9735 | "Neighbor to display information about\n" | |
9736 | "Display detailed prefix count information\n") | |
9737 | { | |
9738 | struct peer *peer; | |
9739 | ||
9740 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9741 | if (! peer) | |
9742 | return CMD_WARNING; | |
9743 | ||
9744 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); | |
9745 | } | |
9746 | ||
9747 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, | |
9748 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
9749 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9750 | SHOW_STR | |
9751 | IP_STR | |
9752 | BGP_STR | |
9753 | "Address family\n" | |
9754 | "Address Family modifier\n" | |
9755 | "Address Family modifier\n" | |
9756 | "Detailed information on TCP and BGP neighbor connections\n" | |
9757 | "Neighbor to display information about\n" | |
9758 | "Neighbor to display information about\n" | |
9759 | "Display detailed prefix count information\n") | |
9760 | { | |
9761 | struct peer *peer; | |
9762 | ||
9763 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9764 | if (! peer) | |
9765 | return CMD_WARNING; | |
9766 | ||
9767 | if (strncmp (argv[0], "m", 1) == 0) | |
9768 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); | |
9769 | ||
9770 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9771 | } | |
9772 | ||
9773 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
9774 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
9775 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9776 | SHOW_STR | |
9777 | IP_STR | |
9778 | BGP_STR | |
9779 | "Address family\n" | |
9780 | "Address Family modifier\n" | |
9781 | "Address Family modifier\n" | |
9782 | "Detailed information on TCP and BGP neighbor connections\n" | |
9783 | "Neighbor to display information about\n" | |
9784 | "Neighbor to display information about\n" | |
9785 | "Display detailed prefix count information\n") | |
9786 | { | |
9787 | struct peer *peer; | |
9788 | ||
9789 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9790 | if (! peer) | |
9791 | return CMD_WARNING; | |
9792 | ||
9793 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); | |
9794 | } | |
9795 | ||
9796 | ||
94f2b392 | 9797 | static void |
718e3744 | 9798 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
9799 | int in) | |
9800 | { | |
9801 | struct bgp_table *table; | |
9802 | struct bgp_adj_in *ain; | |
9803 | struct bgp_adj_out *adj; | |
9804 | unsigned long output_count; | |
9805 | struct bgp_node *rn; | |
9806 | int header1 = 1; | |
9807 | struct bgp *bgp; | |
9808 | int header2 = 1; | |
9809 | ||
bb46e94f | 9810 | bgp = peer->bgp; |
718e3744 | 9811 | |
9812 | if (! bgp) | |
9813 | return; | |
9814 | ||
9815 | table = bgp->rib[afi][safi]; | |
9816 | ||
9817 | output_count = 0; | |
9818 | ||
9819 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], | |
9820 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
9821 | { | |
9822 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9823 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9824 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9825 | |
9826 | vty_out (vty, "Originating default network 0.0.0.0%s%s", | |
9827 | VTY_NEWLINE, VTY_NEWLINE); | |
9828 | header1 = 0; | |
9829 | } | |
9830 | ||
9831 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
9832 | if (in) | |
9833 | { | |
9834 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9835 | if (ain->peer == peer) | |
9836 | { | |
9837 | if (header1) | |
9838 | { | |
9839 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9840 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9841 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9842 | header1 = 0; |
9843 | } | |
9844 | if (header2) | |
9845 | { | |
9846 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9847 | header2 = 0; | |
9848 | } | |
9849 | if (ain->attr) | |
9850 | { | |
9851 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); | |
9852 | output_count++; | |
9853 | } | |
9854 | } | |
9855 | } | |
9856 | else | |
9857 | { | |
9858 | for (adj = rn->adj_out; adj; adj = adj->next) | |
9859 | if (adj->peer == peer) | |
9860 | { | |
9861 | if (header1) | |
9862 | { | |
9863 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9864 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9865 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9866 | header1 = 0; |
9867 | } | |
9868 | if (header2) | |
9869 | { | |
9870 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9871 | header2 = 0; | |
9872 | } | |
9873 | if (adj->attr) | |
9874 | { | |
9875 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); | |
9876 | output_count++; | |
9877 | } | |
9878 | } | |
9879 | } | |
9880 | ||
9881 | if (output_count != 0) | |
9882 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
9883 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
9884 | } | |
9885 | ||
94f2b392 | 9886 | static int |
bb46e94f | 9887 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
9888 | { | |
718e3744 | 9889 | if (! peer || ! peer->afc[afi][safi]) |
9890 | { | |
9891 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9892 | return CMD_WARNING; | |
9893 | } | |
9894 | ||
9895 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9896 | { | |
9897 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", | |
9898 | VTY_NEWLINE); | |
9899 | return CMD_WARNING; | |
9900 | } | |
9901 | ||
9902 | show_adj_route (vty, peer, afi, safi, in); | |
9903 | ||
9904 | return CMD_SUCCESS; | |
9905 | } | |
9906 | ||
2a71e9ce TP |
9907 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
9908 | show_ip_bgp_view_neighbor_advertised_route_cmd, | |
9909 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9910 | SHOW_STR |
9911 | IP_STR | |
9912 | BGP_STR | |
2a71e9ce TP |
9913 | "BGP view\n" |
9914 | "View name\n" | |
718e3744 | 9915 | "Detailed information on TCP and BGP neighbor connections\n" |
9916 | "Neighbor to display information about\n" | |
9917 | "Neighbor to display information about\n" | |
9918 | "Display the routes advertised to a BGP neighbor\n") | |
9919 | { | |
bb46e94f | 9920 | struct peer *peer; |
9921 | ||
2a71e9ce TP |
9922 | if (argc == 2) |
9923 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9924 | else | |
9925 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9926 | ||
bb46e94f | 9927 | if (! peer) |
9928 | return CMD_WARNING; | |
9929 | ||
9930 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); | |
718e3744 | 9931 | } |
9932 | ||
2a71e9ce TP |
9933 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
9934 | show_ip_bgp_neighbor_advertised_route_cmd, | |
9935 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9936 | SHOW_STR | |
9937 | IP_STR | |
9938 | BGP_STR | |
9939 | "Detailed information on TCP and BGP neighbor connections\n" | |
9940 | "Neighbor to display information about\n" | |
9941 | "Neighbor to display information about\n" | |
9942 | "Display the routes advertised to a BGP neighbor\n") | |
9943 | ||
718e3744 | 9944 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
9945 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
9946 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9947 | SHOW_STR | |
9948 | IP_STR | |
9949 | BGP_STR | |
9950 | "Address family\n" | |
9951 | "Address Family modifier\n" | |
9952 | "Address Family modifier\n" | |
9953 | "Detailed information on TCP and BGP neighbor connections\n" | |
9954 | "Neighbor to display information about\n" | |
9955 | "Neighbor to display information about\n" | |
9956 | "Display the routes advertised to a BGP neighbor\n") | |
9957 | { | |
bb46e94f | 9958 | struct peer *peer; |
9959 | ||
9960 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9961 | if (! peer) | |
9962 | return CMD_WARNING; | |
9963 | ||
718e3744 | 9964 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9965 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
718e3744 | 9966 | |
bb46e94f | 9967 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
718e3744 | 9968 | } |
9969 | ||
9970 | #ifdef HAVE_IPV6 | |
bb46e94f | 9971 | DEFUN (show_bgp_view_neighbor_advertised_route, |
9972 | show_bgp_view_neighbor_advertised_route_cmd, | |
9973 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9974 | SHOW_STR |
9975 | BGP_STR | |
bb46e94f | 9976 | "BGP view\n" |
9977 | "View name\n" | |
718e3744 | 9978 | "Detailed information on TCP and BGP neighbor connections\n" |
9979 | "Neighbor to display information about\n" | |
9980 | "Neighbor to display information about\n" | |
9981 | "Display the routes advertised to a BGP neighbor\n") | |
9982 | { | |
bb46e94f | 9983 | struct peer *peer; |
9984 | ||
9985 | if (argc == 2) | |
9986 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9987 | else | |
9988 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9989 | ||
9990 | if (! peer) | |
9991 | return CMD_WARNING; | |
9992 | ||
9993 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); | |
9994 | } | |
9995 | ||
9996 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9997 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, | |
9998 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9999 | SHOW_STR | |
10000 | BGP_STR | |
10001 | "BGP view\n" | |
10002 | "View name\n" | |
10003 | "Address family\n" | |
10004 | "Detailed information on TCP and BGP neighbor connections\n" | |
10005 | "Neighbor to display information about\n" | |
10006 | "Neighbor to display information about\n" | |
10007 | "Display the routes advertised to a BGP neighbor\n") | |
10008 | ||
10009 | DEFUN (show_bgp_view_neighbor_received_routes, | |
10010 | show_bgp_view_neighbor_received_routes_cmd, | |
10011 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10012 | SHOW_STR | |
10013 | BGP_STR | |
10014 | "BGP view\n" | |
10015 | "View name\n" | |
10016 | "Detailed information on TCP and BGP neighbor connections\n" | |
10017 | "Neighbor to display information about\n" | |
10018 | "Neighbor to display information about\n" | |
10019 | "Display the received routes from neighbor\n") | |
10020 | { | |
10021 | struct peer *peer; | |
10022 | ||
10023 | if (argc == 2) | |
10024 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10025 | else | |
10026 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10027 | ||
10028 | if (! peer) | |
10029 | return CMD_WARNING; | |
10030 | ||
10031 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); | |
718e3744 | 10032 | } |
10033 | ||
bb46e94f | 10034 | ALIAS (show_bgp_view_neighbor_received_routes, |
10035 | show_bgp_view_ipv6_neighbor_received_routes_cmd, | |
10036 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10037 | SHOW_STR | |
10038 | BGP_STR | |
10039 | "BGP view\n" | |
10040 | "View name\n" | |
10041 | "Address family\n" | |
10042 | "Detailed information on TCP and BGP neighbor connections\n" | |
10043 | "Neighbor to display information about\n" | |
10044 | "Neighbor to display information about\n" | |
10045 | "Display the received routes from neighbor\n") | |
10046 | ||
10047 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
10048 | show_bgp_neighbor_advertised_route_cmd, | |
10049 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10050 | SHOW_STR | |
10051 | BGP_STR | |
10052 | "Detailed information on TCP and BGP neighbor connections\n" | |
10053 | "Neighbor to display information about\n" | |
10054 | "Neighbor to display information about\n" | |
10055 | "Display the routes advertised to a BGP neighbor\n") | |
10056 | ||
10057 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
718e3744 | 10058 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
10059 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10060 | SHOW_STR | |
10061 | BGP_STR | |
10062 | "Address family\n" | |
10063 | "Detailed information on TCP and BGP neighbor connections\n" | |
10064 | "Neighbor to display information about\n" | |
10065 | "Neighbor to display information about\n" | |
10066 | "Display the routes advertised to a BGP neighbor\n") | |
10067 | ||
10068 | /* old command */ | |
bb46e94f | 10069 | ALIAS (show_bgp_view_neighbor_advertised_route, |
718e3744 | 10070 | ipv6_bgp_neighbor_advertised_route_cmd, |
10071 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10072 | SHOW_STR | |
10073 | IPV6_STR | |
10074 | BGP_STR | |
10075 | "Detailed information on TCP and BGP neighbor connections\n" | |
10076 | "Neighbor to display information about\n" | |
10077 | "Neighbor to display information about\n" | |
10078 | "Display the routes advertised to a BGP neighbor\n") | |
bb46e94f | 10079 | |
718e3744 | 10080 | /* old command */ |
10081 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
10082 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
10083 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10084 | SHOW_STR | |
10085 | IPV6_STR | |
10086 | MBGP_STR | |
10087 | "Detailed information on TCP and BGP neighbor connections\n" | |
10088 | "Neighbor to display information about\n" | |
10089 | "Neighbor to display information about\n" | |
10090 | "Display the routes advertised to a BGP neighbor\n") | |
10091 | { | |
bb46e94f | 10092 | struct peer *peer; |
10093 | ||
10094 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10095 | if (! peer) | |
10096 | return CMD_WARNING; | |
10097 | ||
10098 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); | |
718e3744 | 10099 | } |
10100 | #endif /* HAVE_IPV6 */ | |
10101 | \f | |
2a71e9ce TP |
10102 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
10103 | show_ip_bgp_view_neighbor_received_routes_cmd, | |
10104 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
718e3744 | 10105 | SHOW_STR |
10106 | IP_STR | |
10107 | BGP_STR | |
2a71e9ce TP |
10108 | "BGP view\n" |
10109 | "View name\n" | |
718e3744 | 10110 | "Detailed information on TCP and BGP neighbor connections\n" |
10111 | "Neighbor to display information about\n" | |
10112 | "Neighbor to display information about\n" | |
10113 | "Display the received routes from neighbor\n") | |
10114 | { | |
bb46e94f | 10115 | struct peer *peer; |
10116 | ||
2a71e9ce TP |
10117 | if (argc == 2) |
10118 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10119 | else | |
10120 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10121 | ||
bb46e94f | 10122 | if (! peer) |
10123 | return CMD_WARNING; | |
10124 | ||
10125 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); | |
718e3744 | 10126 | } |
10127 | ||
2a71e9ce TP |
10128 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
10129 | show_ip_bgp_neighbor_received_routes_cmd, | |
10130 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10131 | SHOW_STR | |
10132 | IP_STR | |
10133 | BGP_STR | |
10134 | "Detailed information on TCP and BGP neighbor connections\n" | |
10135 | "Neighbor to display information about\n" | |
10136 | "Neighbor to display information about\n" | |
10137 | "Display the received routes from neighbor\n") | |
10138 | ||
718e3744 | 10139 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
10140 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
10141 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10142 | SHOW_STR | |
10143 | IP_STR | |
10144 | BGP_STR | |
10145 | "Address family\n" | |
10146 | "Address Family modifier\n" | |
10147 | "Address Family modifier\n" | |
10148 | "Detailed information on TCP and BGP neighbor connections\n" | |
10149 | "Neighbor to display information about\n" | |
10150 | "Neighbor to display information about\n" | |
10151 | "Display the received routes from neighbor\n") | |
10152 | { | |
bb46e94f | 10153 | struct peer *peer; |
10154 | ||
10155 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10156 | if (! peer) | |
10157 | return CMD_WARNING; | |
10158 | ||
718e3744 | 10159 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10160 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
718e3744 | 10161 | |
bb46e94f | 10162 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
718e3744 | 10163 | } |
10164 | ||
95cbbd2a ML |
10165 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
10166 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, | |
10167 | #ifdef HAVE_IPV6 | |
10168 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", | |
10169 | #else | |
10170 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", | |
10171 | #endif | |
10172 | SHOW_STR | |
10173 | BGP_STR | |
10174 | "BGP view\n" | |
10175 | "BGP view name\n" | |
10176 | "Address family\n" | |
10177 | #ifdef HAVE_IPV6 | |
10178 | "Address family\n" | |
10179 | #endif | |
10180 | "Address family modifier\n" | |
10181 | "Address family modifier\n" | |
10182 | "Detailed information on TCP and BGP neighbor connections\n" | |
10183 | "Neighbor to display information about\n" | |
10184 | "Neighbor to display information about\n" | |
10185 | "Display the advertised routes to neighbor\n" | |
10186 | "Display the received routes from neighbor\n") | |
10187 | { | |
10188 | int afi; | |
10189 | int safi; | |
10190 | int in; | |
10191 | struct peer *peer; | |
10192 | ||
10193 | #ifdef HAVE_IPV6 | |
10194 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); | |
10195 | #else | |
10196 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10197 | #endif | |
10198 | ||
10199 | if (! peer) | |
10200 | return CMD_WARNING; | |
10201 | ||
10202 | #ifdef HAVE_IPV6 | |
10203 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
10204 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10205 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; | |
10206 | #else | |
10207 | afi = AFI_IP; | |
10208 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10209 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; | |
10210 | #endif | |
10211 | ||
10212 | return peer_adj_routes (vty, peer, afi, safi, in); | |
10213 | } | |
10214 | ||
718e3744 | 10215 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
10216 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
10217 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10218 | SHOW_STR | |
10219 | IP_STR | |
10220 | BGP_STR | |
10221 | "Detailed information on TCP and BGP neighbor connections\n" | |
10222 | "Neighbor to display information about\n" | |
10223 | "Neighbor to display information about\n" | |
10224 | "Display information received from a BGP neighbor\n" | |
10225 | "Display the prefixlist filter\n") | |
10226 | { | |
10227 | char name[BUFSIZ]; | |
c63b83fe | 10228 | union sockunion su; |
718e3744 | 10229 | struct peer *peer; |
c63b83fe | 10230 | int count, ret; |
718e3744 | 10231 | |
c63b83fe JBD |
10232 | ret = str2sockunion (argv[0], &su); |
10233 | if (ret < 0) | |
10234 | { | |
10235 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); | |
10236 | return CMD_WARNING; | |
10237 | } | |
718e3744 | 10238 | |
c63b83fe | 10239 | peer = peer_lookup (NULL, &su); |
718e3744 | 10240 | if (! peer) |
10241 | return CMD_WARNING; | |
10242 | ||
10243 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10244 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10245 | if (count) | |
10246 | { | |
10247 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10248 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10249 | } | |
10250 | ||
10251 | return CMD_SUCCESS; | |
10252 | } | |
10253 | ||
10254 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
10255 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
10256 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10257 | SHOW_STR | |
10258 | IP_STR | |
10259 | BGP_STR | |
10260 | "Address family\n" | |
10261 | "Address Family modifier\n" | |
10262 | "Address Family modifier\n" | |
10263 | "Detailed information on TCP and BGP neighbor connections\n" | |
10264 | "Neighbor to display information about\n" | |
10265 | "Neighbor to display information about\n" | |
10266 | "Display information received from a BGP neighbor\n" | |
10267 | "Display the prefixlist filter\n") | |
10268 | { | |
10269 | char name[BUFSIZ]; | |
c63b83fe | 10270 | union sockunion su; |
718e3744 | 10271 | struct peer *peer; |
c63b83fe | 10272 | int count, ret; |
718e3744 | 10273 | |
c63b83fe JBD |
10274 | ret = str2sockunion (argv[1], &su); |
10275 | if (ret < 0) | |
10276 | { | |
10277 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); | |
10278 | return CMD_WARNING; | |
10279 | } | |
718e3744 | 10280 | |
c63b83fe | 10281 | peer = peer_lookup (NULL, &su); |
718e3744 | 10282 | if (! peer) |
10283 | return CMD_WARNING; | |
10284 | ||
10285 | if (strncmp (argv[0], "m", 1) == 0) | |
10286 | { | |
10287 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
10288 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10289 | if (count) | |
10290 | { | |
10291 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); | |
10292 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10293 | } | |
10294 | } | |
10295 | else | |
10296 | { | |
10297 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10298 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10299 | if (count) | |
10300 | { | |
10301 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10302 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10303 | } | |
10304 | } | |
10305 | ||
10306 | return CMD_SUCCESS; | |
10307 | } | |
10308 | ||
10309 | ||
10310 | #ifdef HAVE_IPV6 | |
bb46e94f | 10311 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10312 | show_bgp_neighbor_received_routes_cmd, |
10313 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10314 | SHOW_STR | |
10315 | BGP_STR | |
10316 | "Detailed information on TCP and BGP neighbor connections\n" | |
10317 | "Neighbor to display information about\n" | |
10318 | "Neighbor to display information about\n" | |
10319 | "Display the received routes from neighbor\n") | |
718e3744 | 10320 | |
bb46e94f | 10321 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10322 | show_bgp_ipv6_neighbor_received_routes_cmd, |
10323 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10324 | SHOW_STR | |
10325 | BGP_STR | |
10326 | "Address family\n" | |
10327 | "Detailed information on TCP and BGP neighbor connections\n" | |
10328 | "Neighbor to display information about\n" | |
10329 | "Neighbor to display information about\n" | |
10330 | "Display the received routes from neighbor\n") | |
10331 | ||
10332 | DEFUN (show_bgp_neighbor_received_prefix_filter, | |
10333 | show_bgp_neighbor_received_prefix_filter_cmd, | |
10334 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10335 | SHOW_STR | |
10336 | BGP_STR | |
10337 | "Detailed information on TCP and BGP neighbor connections\n" | |
10338 | "Neighbor to display information about\n" | |
10339 | "Neighbor to display information about\n" | |
10340 | "Display information received from a BGP neighbor\n" | |
10341 | "Display the prefixlist filter\n") | |
10342 | { | |
10343 | char name[BUFSIZ]; | |
c63b83fe | 10344 | union sockunion su; |
718e3744 | 10345 | struct peer *peer; |
c63b83fe | 10346 | int count, ret; |
718e3744 | 10347 | |
c63b83fe JBD |
10348 | ret = str2sockunion (argv[0], &su); |
10349 | if (ret < 0) | |
10350 | { | |
10351 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); | |
10352 | return CMD_WARNING; | |
10353 | } | |
718e3744 | 10354 | |
c63b83fe | 10355 | peer = peer_lookup (NULL, &su); |
718e3744 | 10356 | if (! peer) |
10357 | return CMD_WARNING; | |
10358 | ||
10359 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10360 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10361 | if (count) | |
10362 | { | |
10363 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10364 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10365 | } | |
10366 | ||
10367 | return CMD_SUCCESS; | |
10368 | } | |
10369 | ||
10370 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
10371 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
10372 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10373 | SHOW_STR | |
10374 | BGP_STR | |
10375 | "Address family\n" | |
10376 | "Detailed information on TCP and BGP neighbor connections\n" | |
10377 | "Neighbor to display information about\n" | |
10378 | "Neighbor to display information about\n" | |
10379 | "Display information received from a BGP neighbor\n" | |
10380 | "Display the prefixlist filter\n") | |
10381 | ||
10382 | /* old command */ | |
bb46e94f | 10383 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10384 | ipv6_bgp_neighbor_received_routes_cmd, |
10385 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10386 | SHOW_STR | |
10387 | IPV6_STR | |
10388 | BGP_STR | |
10389 | "Detailed information on TCP and BGP neighbor connections\n" | |
10390 | "Neighbor to display information about\n" | |
10391 | "Neighbor to display information about\n" | |
10392 | "Display the received routes from neighbor\n") | |
718e3744 | 10393 | |
10394 | /* old command */ | |
10395 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
10396 | ipv6_mbgp_neighbor_received_routes_cmd, | |
10397 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10398 | SHOW_STR | |
10399 | IPV6_STR | |
10400 | MBGP_STR | |
10401 | "Detailed information on TCP and BGP neighbor connections\n" | |
10402 | "Neighbor to display information about\n" | |
10403 | "Neighbor to display information about\n" | |
10404 | "Display the received routes from neighbor\n") | |
10405 | { | |
bb46e94f | 10406 | struct peer *peer; |
10407 | ||
10408 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10409 | if (! peer) | |
10410 | return CMD_WARNING; | |
10411 | ||
10412 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); | |
10413 | } | |
10414 | ||
10415 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, | |
10416 | show_bgp_view_neighbor_received_prefix_filter_cmd, | |
10417 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10418 | SHOW_STR | |
10419 | BGP_STR | |
10420 | "BGP view\n" | |
10421 | "View name\n" | |
10422 | "Detailed information on TCP and BGP neighbor connections\n" | |
10423 | "Neighbor to display information about\n" | |
10424 | "Neighbor to display information about\n" | |
10425 | "Display information received from a BGP neighbor\n" | |
10426 | "Display the prefixlist filter\n") | |
10427 | { | |
10428 | char name[BUFSIZ]; | |
c63b83fe | 10429 | union sockunion su; |
bb46e94f | 10430 | struct peer *peer; |
10431 | struct bgp *bgp; | |
c63b83fe | 10432 | int count, ret; |
bb46e94f | 10433 | |
10434 | /* BGP structure lookup. */ | |
10435 | bgp = bgp_lookup_by_name (argv[0]); | |
10436 | if (bgp == NULL) | |
10437 | { | |
10438 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10439 | return CMD_WARNING; | |
10440 | } | |
10441 | ||
c63b83fe JBD |
10442 | ret = str2sockunion (argv[1], &su); |
10443 | if (ret < 0) | |
10444 | { | |
10445 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); | |
10446 | return CMD_WARNING; | |
10447 | } | |
bb46e94f | 10448 | |
c63b83fe | 10449 | peer = peer_lookup (bgp, &su); |
bb46e94f | 10450 | if (! peer) |
10451 | return CMD_WARNING; | |
10452 | ||
10453 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10454 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10455 | if (count) | |
10456 | { | |
10457 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10458 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10459 | } | |
10460 | ||
10461 | return CMD_SUCCESS; | |
718e3744 | 10462 | } |
bb46e94f | 10463 | |
10464 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, | |
10465 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, | |
10466 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10467 | SHOW_STR | |
10468 | BGP_STR | |
10469 | "BGP view\n" | |
10470 | "View name\n" | |
10471 | "Address family\n" | |
10472 | "Detailed information on TCP and BGP neighbor connections\n" | |
10473 | "Neighbor to display information about\n" | |
10474 | "Neighbor to display information about\n" | |
10475 | "Display information received from a BGP neighbor\n" | |
10476 | "Display the prefixlist filter\n") | |
718e3744 | 10477 | #endif /* HAVE_IPV6 */ |
10478 | \f | |
94f2b392 | 10479 | static int |
bb46e94f | 10480 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
718e3744 | 10481 | safi_t safi, enum bgp_show_type type) |
10482 | { | |
718e3744 | 10483 | if (! peer || ! peer->afc[afi][safi]) |
10484 | { | |
10485 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 10486 | return CMD_WARNING; |
10487 | } | |
10488 | ||
5a646650 | 10489 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
718e3744 | 10490 | } |
10491 | ||
10492 | DEFUN (show_ip_bgp_neighbor_routes, | |
10493 | show_ip_bgp_neighbor_routes_cmd, | |
10494 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10495 | SHOW_STR | |
10496 | IP_STR | |
10497 | BGP_STR | |
10498 | "Detailed information on TCP and BGP neighbor connections\n" | |
10499 | "Neighbor to display information about\n" | |
10500 | "Neighbor to display information about\n" | |
10501 | "Display routes learned from neighbor\n") | |
10502 | { | |
bb46e94f | 10503 | struct peer *peer; |
10504 | ||
10505 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10506 | if (! peer) | |
10507 | return CMD_WARNING; | |
10508 | ||
10509 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10510 | bgp_show_type_neighbor); |
10511 | } | |
10512 | ||
10513 | DEFUN (show_ip_bgp_neighbor_flap, | |
10514 | show_ip_bgp_neighbor_flap_cmd, | |
10515 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10516 | SHOW_STR | |
10517 | IP_STR | |
10518 | BGP_STR | |
10519 | "Detailed information on TCP and BGP neighbor connections\n" | |
10520 | "Neighbor to display information about\n" | |
10521 | "Neighbor to display information about\n" | |
10522 | "Display flap statistics of the routes learned from neighbor\n") | |
10523 | { | |
bb46e94f | 10524 | struct peer *peer; |
10525 | ||
10526 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10527 | if (! peer) | |
10528 | return CMD_WARNING; | |
10529 | ||
10530 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10531 | bgp_show_type_flap_neighbor); |
10532 | } | |
10533 | ||
10534 | DEFUN (show_ip_bgp_neighbor_damp, | |
10535 | show_ip_bgp_neighbor_damp_cmd, | |
10536 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10537 | SHOW_STR | |
10538 | IP_STR | |
10539 | BGP_STR | |
10540 | "Detailed information on TCP and BGP neighbor connections\n" | |
10541 | "Neighbor to display information about\n" | |
10542 | "Neighbor to display information about\n" | |
10543 | "Display the dampened routes received from neighbor\n") | |
10544 | { | |
bb46e94f | 10545 | struct peer *peer; |
10546 | ||
10547 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10548 | if (! peer) | |
10549 | return CMD_WARNING; | |
10550 | ||
10551 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10552 | bgp_show_type_damp_neighbor); |
10553 | } | |
10554 | ||
10555 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
10556 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
10557 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", | |
10558 | SHOW_STR | |
10559 | IP_STR | |
10560 | BGP_STR | |
10561 | "Address family\n" | |
10562 | "Address Family modifier\n" | |
10563 | "Address Family modifier\n" | |
10564 | "Detailed information on TCP and BGP neighbor connections\n" | |
10565 | "Neighbor to display information about\n" | |
10566 | "Neighbor to display information about\n" | |
10567 | "Display routes learned from neighbor\n") | |
10568 | { | |
bb46e94f | 10569 | struct peer *peer; |
10570 | ||
10571 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10572 | if (! peer) | |
10573 | return CMD_WARNING; | |
10574 | ||
718e3744 | 10575 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10576 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
718e3744 | 10577 | bgp_show_type_neighbor); |
10578 | ||
bb46e94f | 10579 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
718e3744 | 10580 | bgp_show_type_neighbor); |
10581 | } | |
bb46e94f | 10582 | |
fee0f4c6 | 10583 | DEFUN (show_ip_bgp_view_rsclient, |
10584 | show_ip_bgp_view_rsclient_cmd, | |
10585 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10586 | SHOW_STR | |
10587 | IP_STR | |
10588 | BGP_STR | |
10589 | "BGP view\n" | |
10590 | "BGP view name\n" | |
10591 | "Information about Route Server Client\n" | |
10592 | NEIGHBOR_ADDR_STR) | |
10593 | { | |
10594 | struct bgp_table *table; | |
10595 | struct peer *peer; | |
10596 | ||
10597 | if (argc == 2) | |
10598 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10599 | else | |
10600 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10601 | ||
10602 | if (! peer) | |
10603 | return CMD_WARNING; | |
10604 | ||
10605 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10606 | { | |
10607 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10608 | VTY_NEWLINE); | |
10609 | return CMD_WARNING; | |
10610 | } | |
10611 | ||
10612 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10613 | PEER_FLAG_RSERVER_CLIENT)) | |
10614 | { | |
10615 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10616 | VTY_NEWLINE); | |
10617 | return CMD_WARNING; | |
10618 | } | |
10619 | ||
10620 | table = peer->rib[AFI_IP][SAFI_UNICAST]; | |
10621 | ||
5a646650 | 10622 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10623 | } |
10624 | ||
10625 | ALIAS (show_ip_bgp_view_rsclient, | |
10626 | show_ip_bgp_rsclient_cmd, | |
10627 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", | |
10628 | SHOW_STR | |
10629 | IP_STR | |
10630 | BGP_STR | |
10631 | "Information about Route Server Client\n" | |
10632 | NEIGHBOR_ADDR_STR) | |
10633 | ||
95cbbd2a ML |
10634 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
10635 | show_bgp_view_ipv4_safi_rsclient_cmd, | |
10636 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
fee0f4c6 | 10637 | SHOW_STR |
fee0f4c6 | 10638 | BGP_STR |
10639 | "BGP view\n" | |
10640 | "BGP view name\n" | |
95cbbd2a ML |
10641 | "Address family\n" |
10642 | "Address Family modifier\n" | |
10643 | "Address Family modifier\n" | |
fee0f4c6 | 10644 | "Information about Route Server Client\n" |
95cbbd2a | 10645 | NEIGHBOR_ADDR_STR) |
fee0f4c6 | 10646 | { |
95cbbd2a | 10647 | struct bgp_table *table; |
fee0f4c6 | 10648 | struct peer *peer; |
95cbbd2a | 10649 | safi_t safi; |
fee0f4c6 | 10650 | |
95cbbd2a ML |
10651 | if (argc == 3) { |
10652 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10653 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10654 | } else { | |
10655 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10656 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10657 | } | |
10658 | ||
10659 | if (! peer) | |
10660 | return CMD_WARNING; | |
10661 | ||
10662 | if (! peer->afc[AFI_IP][safi]) | |
fee0f4c6 | 10663 | { |
95cbbd2a ML |
10664 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
10665 | VTY_NEWLINE); | |
10666 | return CMD_WARNING; | |
10667 | } | |
10668 | ||
10669 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10670 | PEER_FLAG_RSERVER_CLIENT)) | |
10671 | { | |
10672 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10673 | VTY_NEWLINE); | |
10674 | return CMD_WARNING; | |
10675 | } | |
10676 | ||
10677 | table = peer->rib[AFI_IP][safi]; | |
10678 | ||
10679 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); | |
10680 | } | |
10681 | ||
10682 | ALIAS (show_bgp_view_ipv4_safi_rsclient, | |
10683 | show_bgp_ipv4_safi_rsclient_cmd, | |
10684 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
10685 | SHOW_STR | |
10686 | BGP_STR | |
10687 | "Address family\n" | |
10688 | "Address Family modifier\n" | |
10689 | "Address Family modifier\n" | |
10690 | "Information about Route Server Client\n" | |
10691 | NEIGHBOR_ADDR_STR) | |
10692 | ||
10693 | DEFUN (show_ip_bgp_view_rsclient_route, | |
10694 | show_ip_bgp_view_rsclient_route_cmd, | |
10695 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10696 | SHOW_STR | |
10697 | IP_STR | |
10698 | BGP_STR | |
10699 | "BGP view\n" | |
10700 | "BGP view name\n" | |
10701 | "Information about Route Server Client\n" | |
10702 | NEIGHBOR_ADDR_STR | |
10703 | "Network in the BGP routing table to display\n") | |
10704 | { | |
10705 | struct bgp *bgp; | |
10706 | struct peer *peer; | |
10707 | ||
10708 | /* BGP structure lookup. */ | |
10709 | if (argc == 3) | |
10710 | { | |
10711 | bgp = bgp_lookup_by_name (argv[0]); | |
10712 | if (bgp == NULL) | |
10713 | { | |
10714 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10715 | return CMD_WARNING; | |
fee0f4c6 | 10716 | } |
10717 | } | |
10718 | else | |
10719 | { | |
10720 | bgp = bgp_get_default (); | |
10721 | if (bgp == NULL) | |
10722 | { | |
10723 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10724 | return CMD_WARNING; | |
10725 | } | |
10726 | } | |
10727 | ||
10728 | if (argc == 3) | |
10729 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10730 | else | |
10731 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10732 | ||
10733 | if (! peer) | |
10734 | return CMD_WARNING; | |
10735 | ||
10736 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10737 | { | |
10738 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10739 | VTY_NEWLINE); | |
10740 | return CMD_WARNING; | |
10741 | } | |
10742 | ||
10743 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10744 | PEER_FLAG_RSERVER_CLIENT)) | |
10745 | { | |
10746 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10747 | VTY_NEWLINE); | |
10748 | return CMD_WARNING; | |
10749 | } | |
10750 | ||
10751 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10752 | (argc == 3) ? argv[2] : argv[1], | |
10753 | AFI_IP, SAFI_UNICAST, NULL, 0); | |
10754 | } | |
10755 | ||
10756 | ALIAS (show_ip_bgp_view_rsclient_route, | |
10757 | show_ip_bgp_rsclient_route_cmd, | |
10758 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10759 | SHOW_STR | |
10760 | IP_STR | |
10761 | BGP_STR | |
10762 | "Information about Route Server Client\n" | |
10763 | NEIGHBOR_ADDR_STR | |
10764 | "Network in the BGP routing table to display\n") | |
10765 | ||
95cbbd2a ML |
10766 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
10767 | show_bgp_view_ipv4_safi_rsclient_route_cmd, | |
10768 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10769 | SHOW_STR | |
10770 | BGP_STR | |
10771 | "BGP view\n" | |
10772 | "BGP view name\n" | |
10773 | "Address family\n" | |
10774 | "Address Family modifier\n" | |
10775 | "Address Family modifier\n" | |
10776 | "Information about Route Server Client\n" | |
10777 | NEIGHBOR_ADDR_STR | |
10778 | "Network in the BGP routing table to display\n") | |
10779 | { | |
10780 | struct bgp *bgp; | |
10781 | struct peer *peer; | |
10782 | safi_t safi; | |
10783 | ||
10784 | /* BGP structure lookup. */ | |
10785 | if (argc == 4) | |
10786 | { | |
10787 | bgp = bgp_lookup_by_name (argv[0]); | |
10788 | if (bgp == NULL) | |
10789 | { | |
10790 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10791 | return CMD_WARNING; | |
10792 | } | |
10793 | } | |
10794 | else | |
10795 | { | |
10796 | bgp = bgp_get_default (); | |
10797 | if (bgp == NULL) | |
10798 | { | |
10799 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10800 | return CMD_WARNING; | |
10801 | } | |
10802 | } | |
10803 | ||
10804 | if (argc == 4) { | |
10805 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10806 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10807 | } else { | |
10808 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10809 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10810 | } | |
10811 | ||
10812 | if (! peer) | |
10813 | return CMD_WARNING; | |
10814 | ||
10815 | if (! peer->afc[AFI_IP][safi]) | |
10816 | { | |
10817 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10818 | VTY_NEWLINE); | |
10819 | return CMD_WARNING; | |
10820 | } | |
10821 | ||
10822 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10823 | PEER_FLAG_RSERVER_CLIENT)) | |
10824 | { | |
10825 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10826 | VTY_NEWLINE); | |
10827 | return CMD_WARNING; | |
10828 | } | |
10829 | ||
10830 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], | |
10831 | (argc == 4) ? argv[3] : argv[2], | |
10832 | AFI_IP, safi, NULL, 0); | |
10833 | } | |
10834 | ||
10835 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, | |
10836 | show_bgp_ipv4_safi_rsclient_route_cmd, | |
10837 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10838 | SHOW_STR | |
10839 | BGP_STR | |
10840 | "Address family\n" | |
10841 | "Address Family modifier\n" | |
10842 | "Address Family modifier\n" | |
10843 | "Information about Route Server Client\n" | |
10844 | NEIGHBOR_ADDR_STR | |
10845 | "Network in the BGP routing table to display\n") | |
10846 | ||
fee0f4c6 | 10847 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
10848 | show_ip_bgp_view_rsclient_prefix_cmd, | |
10849 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10850 | SHOW_STR | |
10851 | IP_STR | |
10852 | BGP_STR | |
10853 | "BGP view\n" | |
10854 | "BGP view name\n" | |
10855 | "Information about Route Server Client\n" | |
10856 | NEIGHBOR_ADDR_STR | |
10857 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10858 | { | |
10859 | struct bgp *bgp; | |
10860 | struct peer *peer; | |
10861 | ||
10862 | /* BGP structure lookup. */ | |
10863 | if (argc == 3) | |
10864 | { | |
10865 | bgp = bgp_lookup_by_name (argv[0]); | |
10866 | if (bgp == NULL) | |
10867 | { | |
10868 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10869 | return CMD_WARNING; | |
10870 | } | |
10871 | } | |
10872 | else | |
10873 | { | |
10874 | bgp = bgp_get_default (); | |
10875 | if (bgp == NULL) | |
10876 | { | |
10877 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10878 | return CMD_WARNING; | |
10879 | } | |
10880 | } | |
10881 | ||
10882 | if (argc == 3) | |
10883 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10884 | else | |
10885 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10886 | ||
10887 | if (! peer) | |
10888 | return CMD_WARNING; | |
10889 | ||
10890 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10891 | { | |
10892 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10893 | VTY_NEWLINE); | |
10894 | return CMD_WARNING; | |
10895 | } | |
10896 | ||
10897 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10898 | PEER_FLAG_RSERVER_CLIENT)) | |
10899 | { | |
10900 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10901 | VTY_NEWLINE); | |
10902 | return CMD_WARNING; | |
10903 | } | |
10904 | ||
10905 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10906 | (argc == 3) ? argv[2] : argv[1], | |
10907 | AFI_IP, SAFI_UNICAST, NULL, 1); | |
10908 | } | |
10909 | ||
10910 | ALIAS (show_ip_bgp_view_rsclient_prefix, | |
10911 | show_ip_bgp_rsclient_prefix_cmd, | |
10912 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10913 | SHOW_STR | |
10914 | IP_STR | |
10915 | BGP_STR | |
10916 | "Information about Route Server Client\n" | |
10917 | NEIGHBOR_ADDR_STR | |
10918 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10919 | ||
95cbbd2a ML |
10920 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
10921 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, | |
10922 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10923 | SHOW_STR | |
10924 | BGP_STR | |
10925 | "BGP view\n" | |
10926 | "BGP view name\n" | |
10927 | "Address family\n" | |
10928 | "Address Family modifier\n" | |
10929 | "Address Family modifier\n" | |
10930 | "Information about Route Server Client\n" | |
10931 | NEIGHBOR_ADDR_STR | |
10932 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10933 | { | |
10934 | struct bgp *bgp; | |
10935 | struct peer *peer; | |
10936 | safi_t safi; | |
10937 | ||
10938 | /* BGP structure lookup. */ | |
10939 | if (argc == 4) | |
10940 | { | |
10941 | bgp = bgp_lookup_by_name (argv[0]); | |
10942 | if (bgp == NULL) | |
10943 | { | |
10944 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10945 | return CMD_WARNING; | |
10946 | } | |
10947 | } | |
10948 | else | |
10949 | { | |
10950 | bgp = bgp_get_default (); | |
10951 | if (bgp == NULL) | |
10952 | { | |
10953 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10954 | return CMD_WARNING; | |
10955 | } | |
10956 | } | |
10957 | ||
10958 | if (argc == 4) { | |
10959 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10960 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10961 | } else { | |
10962 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10963 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10964 | } | |
10965 | ||
10966 | if (! peer) | |
10967 | return CMD_WARNING; | |
10968 | ||
10969 | if (! peer->afc[AFI_IP][safi]) | |
10970 | { | |
10971 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10972 | VTY_NEWLINE); | |
10973 | return CMD_WARNING; | |
10974 | } | |
10975 | ||
10976 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10977 | PEER_FLAG_RSERVER_CLIENT)) | |
10978 | { | |
10979 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10980 | VTY_NEWLINE); | |
10981 | return CMD_WARNING; | |
10982 | } | |
10983 | ||
10984 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], | |
10985 | (argc == 4) ? argv[3] : argv[2], | |
10986 | AFI_IP, safi, NULL, 1); | |
10987 | } | |
10988 | ||
10989 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, | |
10990 | show_bgp_ipv4_safi_rsclient_prefix_cmd, | |
10991 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10992 | SHOW_STR | |
10993 | BGP_STR | |
10994 | "Address family\n" | |
10995 | "Address Family modifier\n" | |
10996 | "Address Family modifier\n" | |
10997 | "Information about Route Server Client\n" | |
10998 | NEIGHBOR_ADDR_STR | |
10999 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
fee0f4c6 | 11000 | |
718e3744 | 11001 | #ifdef HAVE_IPV6 |
bb46e94f | 11002 | DEFUN (show_bgp_view_neighbor_routes, |
11003 | show_bgp_view_neighbor_routes_cmd, | |
11004 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", | |
718e3744 | 11005 | SHOW_STR |
11006 | BGP_STR | |
bb46e94f | 11007 | "BGP view\n" |
11008 | "BGP view name\n" | |
718e3744 | 11009 | "Detailed information on TCP and BGP neighbor connections\n" |
11010 | "Neighbor to display information about\n" | |
11011 | "Neighbor to display information about\n" | |
11012 | "Display routes learned from neighbor\n") | |
11013 | { | |
bb46e94f | 11014 | struct peer *peer; |
11015 | ||
11016 | if (argc == 2) | |
11017 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11018 | else | |
11019 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11020 | ||
11021 | if (! peer) | |
11022 | return CMD_WARNING; | |
11023 | ||
11024 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
718e3744 | 11025 | bgp_show_type_neighbor); |
11026 | } | |
11027 | ||
bb46e94f | 11028 | ALIAS (show_bgp_view_neighbor_routes, |
11029 | show_bgp_view_ipv6_neighbor_routes_cmd, | |
11030 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
11031 | SHOW_STR | |
11032 | BGP_STR | |
11033 | "BGP view\n" | |
11034 | "BGP view name\n" | |
11035 | "Address family\n" | |
11036 | "Detailed information on TCP and BGP neighbor connections\n" | |
11037 | "Neighbor to display information about\n" | |
11038 | "Neighbor to display information about\n" | |
11039 | "Display routes learned from neighbor\n") | |
11040 | ||
11041 | DEFUN (show_bgp_view_neighbor_damp, | |
11042 | show_bgp_view_neighbor_damp_cmd, | |
11043 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11044 | SHOW_STR | |
11045 | BGP_STR | |
11046 | "BGP view\n" | |
11047 | "BGP view name\n" | |
11048 | "Detailed information on TCP and BGP neighbor connections\n" | |
11049 | "Neighbor to display information about\n" | |
11050 | "Neighbor to display information about\n" | |
11051 | "Display the dampened routes received from neighbor\n") | |
11052 | { | |
11053 | struct peer *peer; | |
11054 | ||
11055 | if (argc == 2) | |
11056 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11057 | else | |
11058 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11059 | ||
11060 | if (! peer) | |
11061 | return CMD_WARNING; | |
11062 | ||
11063 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
11064 | bgp_show_type_damp_neighbor); | |
11065 | } | |
11066 | ||
11067 | ALIAS (show_bgp_view_neighbor_damp, | |
11068 | show_bgp_view_ipv6_neighbor_damp_cmd, | |
11069 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11070 | SHOW_STR | |
11071 | BGP_STR | |
11072 | "BGP view\n" | |
11073 | "BGP view name\n" | |
11074 | "Address family\n" | |
11075 | "Detailed information on TCP and BGP neighbor connections\n" | |
11076 | "Neighbor to display information about\n" | |
11077 | "Neighbor to display information about\n" | |
11078 | "Display the dampened routes received from neighbor\n") | |
11079 | ||
11080 | DEFUN (show_bgp_view_neighbor_flap, | |
11081 | show_bgp_view_neighbor_flap_cmd, | |
11082 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11083 | SHOW_STR | |
11084 | BGP_STR | |
11085 | "BGP view\n" | |
11086 | "BGP view name\n" | |
11087 | "Detailed information on TCP and BGP neighbor connections\n" | |
11088 | "Neighbor to display information about\n" | |
11089 | "Neighbor to display information about\n" | |
11090 | "Display flap statistics of the routes learned from neighbor\n") | |
11091 | { | |
11092 | struct peer *peer; | |
11093 | ||
11094 | if (argc == 2) | |
11095 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11096 | else | |
11097 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11098 | ||
11099 | if (! peer) | |
11100 | return CMD_WARNING; | |
11101 | ||
11102 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
11103 | bgp_show_type_flap_neighbor); | |
11104 | } | |
11105 | ||
11106 | ALIAS (show_bgp_view_neighbor_flap, | |
11107 | show_bgp_view_ipv6_neighbor_flap_cmd, | |
11108 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11109 | SHOW_STR | |
11110 | BGP_STR | |
11111 | "BGP view\n" | |
11112 | "BGP view name\n" | |
11113 | "Address family\n" | |
11114 | "Detailed information on TCP and BGP neighbor connections\n" | |
11115 | "Neighbor to display information about\n" | |
11116 | "Neighbor to display information about\n" | |
11117 | "Display flap statistics of the routes learned from neighbor\n") | |
11118 | ||
11119 | ALIAS (show_bgp_view_neighbor_routes, | |
11120 | show_bgp_neighbor_routes_cmd, | |
11121 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11122 | SHOW_STR | |
11123 | BGP_STR | |
11124 | "Detailed information on TCP and BGP neighbor connections\n" | |
11125 | "Neighbor to display information about\n" | |
11126 | "Neighbor to display information about\n" | |
11127 | "Display routes learned from neighbor\n") | |
11128 | ||
11129 | ||
11130 | ALIAS (show_bgp_view_neighbor_routes, | |
718e3744 | 11131 | show_bgp_ipv6_neighbor_routes_cmd, |
11132 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
11133 | SHOW_STR | |
11134 | BGP_STR | |
11135 | "Address family\n" | |
11136 | "Detailed information on TCP and BGP neighbor connections\n" | |
11137 | "Neighbor to display information about\n" | |
11138 | "Neighbor to display information about\n" | |
11139 | "Display routes learned from neighbor\n") | |
11140 | ||
11141 | /* old command */ | |
bb46e94f | 11142 | ALIAS (show_bgp_view_neighbor_routes, |
718e3744 | 11143 | ipv6_bgp_neighbor_routes_cmd, |
11144 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11145 | SHOW_STR | |
11146 | IPV6_STR | |
11147 | BGP_STR | |
11148 | "Detailed information on TCP and BGP neighbor connections\n" | |
11149 | "Neighbor to display information about\n" | |
11150 | "Neighbor to display information about\n" | |
11151 | "Display routes learned from neighbor\n") | |
718e3744 | 11152 | |
11153 | /* old command */ | |
11154 | DEFUN (ipv6_mbgp_neighbor_routes, | |
11155 | ipv6_mbgp_neighbor_routes_cmd, | |
11156 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11157 | SHOW_STR | |
11158 | IPV6_STR | |
11159 | MBGP_STR | |
11160 | "Detailed information on TCP and BGP neighbor connections\n" | |
11161 | "Neighbor to display information about\n" | |
11162 | "Neighbor to display information about\n" | |
11163 | "Display routes learned from neighbor\n") | |
11164 | { | |
bb46e94f | 11165 | struct peer *peer; |
11166 | ||
11167 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11168 | if (! peer) | |
11169 | return CMD_WARNING; | |
11170 | ||
11171 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, | |
718e3744 | 11172 | bgp_show_type_neighbor); |
11173 | } | |
bb46e94f | 11174 | |
11175 | ALIAS (show_bgp_view_neighbor_flap, | |
11176 | show_bgp_neighbor_flap_cmd, | |
11177 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11178 | SHOW_STR | |
11179 | BGP_STR | |
11180 | "Detailed information on TCP and BGP neighbor connections\n" | |
11181 | "Neighbor to display information about\n" | |
11182 | "Neighbor to display information about\n" | |
11183 | "Display flap statistics of the routes learned from neighbor\n") | |
11184 | ||
11185 | ALIAS (show_bgp_view_neighbor_flap, | |
11186 | show_bgp_ipv6_neighbor_flap_cmd, | |
11187 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11188 | SHOW_STR | |
11189 | BGP_STR | |
11190 | "Address family\n" | |
11191 | "Detailed information on TCP and BGP neighbor connections\n" | |
11192 | "Neighbor to display information about\n" | |
11193 | "Neighbor to display information about\n" | |
11194 | "Display flap statistics of the routes learned from neighbor\n") | |
11195 | ||
11196 | ALIAS (show_bgp_view_neighbor_damp, | |
11197 | show_bgp_neighbor_damp_cmd, | |
11198 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11199 | SHOW_STR | |
11200 | BGP_STR | |
11201 | "Detailed information on TCP and BGP neighbor connections\n" | |
11202 | "Neighbor to display information about\n" | |
11203 | "Neighbor to display information about\n" | |
11204 | "Display the dampened routes received from neighbor\n") | |
11205 | ||
11206 | ALIAS (show_bgp_view_neighbor_damp, | |
11207 | show_bgp_ipv6_neighbor_damp_cmd, | |
11208 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11209 | SHOW_STR | |
11210 | BGP_STR | |
11211 | "Address family\n" | |
11212 | "Detailed information on TCP and BGP neighbor connections\n" | |
11213 | "Neighbor to display information about\n" | |
11214 | "Neighbor to display information about\n" | |
c001ae62 | 11215 | "Display the dampened routes received from neighbor\n") |
fee0f4c6 | 11216 | |
11217 | DEFUN (show_bgp_view_rsclient, | |
11218 | show_bgp_view_rsclient_cmd, | |
11219 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
11220 | SHOW_STR | |
11221 | BGP_STR | |
11222 | "BGP view\n" | |
11223 | "BGP view name\n" | |
11224 | "Information about Route Server Client\n" | |
11225 | NEIGHBOR_ADDR_STR) | |
11226 | { | |
11227 | struct bgp_table *table; | |
11228 | struct peer *peer; | |
11229 | ||
11230 | if (argc == 2) | |
11231 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11232 | else | |
11233 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11234 | ||
11235 | if (! peer) | |
11236 | return CMD_WARNING; | |
11237 | ||
11238 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11239 | { | |
11240 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11241 | VTY_NEWLINE); | |
11242 | return CMD_WARNING; | |
11243 | } | |
11244 | ||
11245 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11246 | PEER_FLAG_RSERVER_CLIENT)) | |
11247 | { | |
11248 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11249 | VTY_NEWLINE); | |
11250 | return CMD_WARNING; | |
11251 | } | |
11252 | ||
11253 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; | |
11254 | ||
5a646650 | 11255 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 11256 | } |
11257 | ||
11258 | ALIAS (show_bgp_view_rsclient, | |
11259 | show_bgp_rsclient_cmd, | |
11260 | "show bgp rsclient (A.B.C.D|X:X::X:X)", | |
11261 | SHOW_STR | |
11262 | BGP_STR | |
11263 | "Information about Route Server Client\n" | |
11264 | NEIGHBOR_ADDR_STR) | |
11265 | ||
95cbbd2a ML |
11266 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
11267 | show_bgp_view_ipv6_safi_rsclient_cmd, | |
11268 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
11269 | SHOW_STR | |
11270 | BGP_STR | |
11271 | "BGP view\n" | |
11272 | "BGP view name\n" | |
11273 | "Address family\n" | |
11274 | "Address Family modifier\n" | |
11275 | "Address Family modifier\n" | |
11276 | "Information about Route Server Client\n" | |
11277 | NEIGHBOR_ADDR_STR) | |
11278 | { | |
11279 | struct bgp_table *table; | |
11280 | struct peer *peer; | |
11281 | safi_t safi; | |
11282 | ||
11283 | if (argc == 3) { | |
11284 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11285 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11286 | } else { | |
11287 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11288 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11289 | } | |
11290 | ||
11291 | if (! peer) | |
11292 | return CMD_WARNING; | |
11293 | ||
11294 | if (! peer->afc[AFI_IP6][safi]) | |
11295 | { | |
11296 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11297 | VTY_NEWLINE); | |
11298 | return CMD_WARNING; | |
11299 | } | |
11300 | ||
11301 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11302 | PEER_FLAG_RSERVER_CLIENT)) | |
11303 | { | |
11304 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11305 | VTY_NEWLINE); | |
11306 | return CMD_WARNING; | |
11307 | } | |
11308 | ||
11309 | table = peer->rib[AFI_IP6][safi]; | |
11310 | ||
11311 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); | |
11312 | } | |
11313 | ||
11314 | ALIAS (show_bgp_view_ipv6_safi_rsclient, | |
11315 | show_bgp_ipv6_safi_rsclient_cmd, | |
11316 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
11317 | SHOW_STR | |
11318 | BGP_STR | |
11319 | "Address family\n" | |
11320 | "Address Family modifier\n" | |
11321 | "Address Family modifier\n" | |
11322 | "Information about Route Server Client\n" | |
11323 | NEIGHBOR_ADDR_STR) | |
11324 | ||
fee0f4c6 | 11325 | DEFUN (show_bgp_view_rsclient_route, |
11326 | show_bgp_view_rsclient_route_cmd, | |
11327 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11328 | SHOW_STR | |
11329 | BGP_STR | |
11330 | "BGP view\n" | |
11331 | "BGP view name\n" | |
11332 | "Information about Route Server Client\n" | |
11333 | NEIGHBOR_ADDR_STR | |
11334 | "Network in the BGP routing table to display\n") | |
11335 | { | |
11336 | struct bgp *bgp; | |
11337 | struct peer *peer; | |
11338 | ||
11339 | /* BGP structure lookup. */ | |
11340 | if (argc == 3) | |
11341 | { | |
11342 | bgp = bgp_lookup_by_name (argv[0]); | |
11343 | if (bgp == NULL) | |
11344 | { | |
11345 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11346 | return CMD_WARNING; | |
11347 | } | |
11348 | } | |
11349 | else | |
11350 | { | |
11351 | bgp = bgp_get_default (); | |
11352 | if (bgp == NULL) | |
11353 | { | |
11354 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11355 | return CMD_WARNING; | |
11356 | } | |
11357 | } | |
11358 | ||
11359 | if (argc == 3) | |
11360 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11361 | else | |
11362 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11363 | ||
11364 | if (! peer) | |
11365 | return CMD_WARNING; | |
11366 | ||
11367 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11368 | { | |
11369 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11370 | VTY_NEWLINE); | |
11371 | return CMD_WARNING; | |
11372 | } | |
11373 | ||
11374 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11375 | PEER_FLAG_RSERVER_CLIENT)) | |
11376 | { | |
11377 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11378 | VTY_NEWLINE); | |
11379 | return CMD_WARNING; | |
11380 | } | |
11381 | ||
11382 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
11383 | (argc == 3) ? argv[2] : argv[1], | |
11384 | AFI_IP6, SAFI_UNICAST, NULL, 0); | |
11385 | } | |
11386 | ||
11387 | ALIAS (show_bgp_view_rsclient_route, | |
11388 | show_bgp_rsclient_route_cmd, | |
11389 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11390 | SHOW_STR | |
11391 | BGP_STR | |
11392 | "Information about Route Server Client\n" | |
11393 | NEIGHBOR_ADDR_STR | |
11394 | "Network in the BGP routing table to display\n") | |
11395 | ||
95cbbd2a ML |
11396 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
11397 | show_bgp_view_ipv6_safi_rsclient_route_cmd, | |
11398 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11399 | SHOW_STR | |
11400 | BGP_STR | |
11401 | "BGP view\n" | |
11402 | "BGP view name\n" | |
11403 | "Address family\n" | |
11404 | "Address Family modifier\n" | |
11405 | "Address Family modifier\n" | |
11406 | "Information about Route Server Client\n" | |
11407 | NEIGHBOR_ADDR_STR | |
11408 | "Network in the BGP routing table to display\n") | |
11409 | { | |
11410 | struct bgp *bgp; | |
11411 | struct peer *peer; | |
11412 | safi_t safi; | |
11413 | ||
11414 | /* BGP structure lookup. */ | |
11415 | if (argc == 4) | |
11416 | { | |
11417 | bgp = bgp_lookup_by_name (argv[0]); | |
11418 | if (bgp == NULL) | |
11419 | { | |
11420 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11421 | return CMD_WARNING; | |
11422 | } | |
11423 | } | |
11424 | else | |
11425 | { | |
11426 | bgp = bgp_get_default (); | |
11427 | if (bgp == NULL) | |
11428 | { | |
11429 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11430 | return CMD_WARNING; | |
11431 | } | |
11432 | } | |
11433 | ||
11434 | if (argc == 4) { | |
11435 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11436 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11437 | } else { | |
11438 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11439 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11440 | } | |
11441 | ||
11442 | if (! peer) | |
11443 | return CMD_WARNING; | |
11444 | ||
11445 | if (! peer->afc[AFI_IP6][safi]) | |
11446 | { | |
11447 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11448 | VTY_NEWLINE); | |
11449 | return CMD_WARNING; | |
11450 | } | |
11451 | ||
11452 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11453 | PEER_FLAG_RSERVER_CLIENT)) | |
11454 | { | |
11455 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11456 | VTY_NEWLINE); | |
11457 | return CMD_WARNING; | |
11458 | } | |
11459 | ||
11460 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], | |
11461 | (argc == 4) ? argv[3] : argv[2], | |
11462 | AFI_IP6, safi, NULL, 0); | |
11463 | } | |
11464 | ||
11465 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, | |
11466 | show_bgp_ipv6_safi_rsclient_route_cmd, | |
11467 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11468 | SHOW_STR | |
11469 | BGP_STR | |
11470 | "Address family\n" | |
11471 | "Address Family modifier\n" | |
11472 | "Address Family modifier\n" | |
11473 | "Information about Route Server Client\n" | |
11474 | NEIGHBOR_ADDR_STR | |
11475 | "Network in the BGP routing table to display\n") | |
11476 | ||
fee0f4c6 | 11477 | DEFUN (show_bgp_view_rsclient_prefix, |
11478 | show_bgp_view_rsclient_prefix_cmd, | |
11479 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11480 | SHOW_STR | |
11481 | BGP_STR | |
11482 | "BGP view\n" | |
11483 | "BGP view name\n" | |
11484 | "Information about Route Server Client\n" | |
11485 | NEIGHBOR_ADDR_STR | |
11486 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11487 | { | |
11488 | struct bgp *bgp; | |
11489 | struct peer *peer; | |
11490 | ||
11491 | /* BGP structure lookup. */ | |
11492 | if (argc == 3) | |
11493 | { | |
11494 | bgp = bgp_lookup_by_name (argv[0]); | |
11495 | if (bgp == NULL) | |
11496 | { | |
11497 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11498 | return CMD_WARNING; | |
11499 | } | |
11500 | } | |
11501 | else | |
11502 | { | |
11503 | bgp = bgp_get_default (); | |
11504 | if (bgp == NULL) | |
11505 | { | |
11506 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11507 | return CMD_WARNING; | |
11508 | } | |
11509 | } | |
11510 | ||
11511 | if (argc == 3) | |
11512 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11513 | else | |
11514 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11515 | ||
11516 | if (! peer) | |
11517 | return CMD_WARNING; | |
11518 | ||
11519 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11520 | { | |
11521 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11522 | VTY_NEWLINE); | |
11523 | return CMD_WARNING; | |
11524 | } | |
11525 | ||
11526 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11527 | PEER_FLAG_RSERVER_CLIENT)) | |
11528 | { | |
11529 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11530 | VTY_NEWLINE); | |
11531 | return CMD_WARNING; | |
11532 | } | |
11533 | ||
11534 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
11535 | (argc == 3) ? argv[2] : argv[1], | |
11536 | AFI_IP6, SAFI_UNICAST, NULL, 1); | |
11537 | } | |
11538 | ||
11539 | ALIAS (show_bgp_view_rsclient_prefix, | |
11540 | show_bgp_rsclient_prefix_cmd, | |
11541 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11542 | SHOW_STR | |
11543 | BGP_STR | |
11544 | "Information about Route Server Client\n" | |
11545 | NEIGHBOR_ADDR_STR | |
11546 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11547 | ||
95cbbd2a ML |
11548 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
11549 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, | |
11550 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11551 | SHOW_STR | |
11552 | BGP_STR | |
11553 | "BGP view\n" | |
11554 | "BGP view name\n" | |
11555 | "Address family\n" | |
11556 | "Address Family modifier\n" | |
11557 | "Address Family modifier\n" | |
11558 | "Information about Route Server Client\n" | |
11559 | NEIGHBOR_ADDR_STR | |
11560 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11561 | { | |
11562 | struct bgp *bgp; | |
11563 | struct peer *peer; | |
11564 | safi_t safi; | |
11565 | ||
11566 | /* BGP structure lookup. */ | |
11567 | if (argc == 4) | |
11568 | { | |
11569 | bgp = bgp_lookup_by_name (argv[0]); | |
11570 | if (bgp == NULL) | |
11571 | { | |
11572 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11573 | return CMD_WARNING; | |
11574 | } | |
11575 | } | |
11576 | else | |
11577 | { | |
11578 | bgp = bgp_get_default (); | |
11579 | if (bgp == NULL) | |
11580 | { | |
11581 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11582 | return CMD_WARNING; | |
11583 | } | |
11584 | } | |
11585 | ||
11586 | if (argc == 4) { | |
11587 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11588 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11589 | } else { | |
11590 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11591 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11592 | } | |
11593 | ||
11594 | if (! peer) | |
11595 | return CMD_WARNING; | |
11596 | ||
11597 | if (! peer->afc[AFI_IP6][safi]) | |
11598 | { | |
11599 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11600 | VTY_NEWLINE); | |
11601 | return CMD_WARNING; | |
11602 | } | |
11603 | ||
11604 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11605 | PEER_FLAG_RSERVER_CLIENT)) | |
11606 | { | |
11607 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11608 | VTY_NEWLINE); | |
11609 | return CMD_WARNING; | |
11610 | } | |
11611 | ||
11612 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], | |
11613 | (argc == 4) ? argv[3] : argv[2], | |
11614 | AFI_IP6, safi, NULL, 1); | |
11615 | } | |
11616 | ||
11617 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, | |
11618 | show_bgp_ipv6_safi_rsclient_prefix_cmd, | |
11619 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11620 | SHOW_STR | |
11621 | BGP_STR | |
11622 | "Address family\n" | |
11623 | "Address Family modifier\n" | |
11624 | "Address Family modifier\n" | |
11625 | "Information about Route Server Client\n" | |
11626 | NEIGHBOR_ADDR_STR | |
11627 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11628 | ||
718e3744 | 11629 | #endif /* HAVE_IPV6 */ |
11630 | \f | |
11631 | struct bgp_table *bgp_distance_table; | |
11632 | ||
11633 | struct bgp_distance | |
11634 | { | |
11635 | /* Distance value for the IP source prefix. */ | |
11636 | u_char distance; | |
11637 | ||
11638 | /* Name of the access-list to be matched. */ | |
11639 | char *access_list; | |
11640 | }; | |
11641 | ||
94f2b392 | 11642 | static struct bgp_distance * |
66e5cd87 | 11643 | bgp_distance_new (void) |
718e3744 | 11644 | { |
393deb9b | 11645 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 11646 | } |
11647 | ||
94f2b392 | 11648 | static void |
718e3744 | 11649 | bgp_distance_free (struct bgp_distance *bdistance) |
11650 | { | |
11651 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
11652 | } | |
11653 | ||
94f2b392 | 11654 | static int |
fd79ac91 | 11655 | bgp_distance_set (struct vty *vty, const char *distance_str, |
11656 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11657 | { |
11658 | int ret; | |
11659 | struct prefix_ipv4 p; | |
11660 | u_char distance; | |
11661 | struct bgp_node *rn; | |
11662 | struct bgp_distance *bdistance; | |
11663 | ||
11664 | ret = str2prefix_ipv4 (ip_str, &p); | |
11665 | if (ret == 0) | |
11666 | { | |
11667 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11668 | return CMD_WARNING; | |
11669 | } | |
11670 | ||
11671 | distance = atoi (distance_str); | |
11672 | ||
11673 | /* Get BGP distance node. */ | |
11674 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
11675 | if (rn->info) | |
11676 | { | |
11677 | bdistance = rn->info; | |
11678 | bgp_unlock_node (rn); | |
11679 | } | |
11680 | else | |
11681 | { | |
11682 | bdistance = bgp_distance_new (); | |
11683 | rn->info = bdistance; | |
11684 | } | |
11685 | ||
11686 | /* Set distance value. */ | |
11687 | bdistance->distance = distance; | |
11688 | ||
11689 | /* Reset access-list configuration. */ | |
11690 | if (bdistance->access_list) | |
11691 | { | |
11692 | free (bdistance->access_list); | |
11693 | bdistance->access_list = NULL; | |
11694 | } | |
11695 | if (access_list_str) | |
11696 | bdistance->access_list = strdup (access_list_str); | |
11697 | ||
11698 | return CMD_SUCCESS; | |
11699 | } | |
11700 | ||
94f2b392 | 11701 | static int |
fd79ac91 | 11702 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
11703 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11704 | { |
11705 | int ret; | |
11706 | struct prefix_ipv4 p; | |
11707 | u_char distance; | |
11708 | struct bgp_node *rn; | |
11709 | struct bgp_distance *bdistance; | |
11710 | ||
11711 | ret = str2prefix_ipv4 (ip_str, &p); | |
11712 | if (ret == 0) | |
11713 | { | |
11714 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11715 | return CMD_WARNING; | |
11716 | } | |
11717 | ||
11718 | distance = atoi (distance_str); | |
11719 | ||
11720 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); | |
11721 | if (! rn) | |
11722 | { | |
11723 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
11724 | return CMD_WARNING; | |
11725 | } | |
11726 | ||
11727 | bdistance = rn->info; | |
11728 | ||
11729 | if (bdistance->access_list) | |
11730 | free (bdistance->access_list); | |
11731 | bgp_distance_free (bdistance); | |
11732 | ||
11733 | rn->info = NULL; | |
11734 | bgp_unlock_node (rn); | |
11735 | bgp_unlock_node (rn); | |
11736 | ||
11737 | return CMD_SUCCESS; | |
11738 | } | |
11739 | ||
718e3744 | 11740 | /* Apply BGP information to distance method. */ |
11741 | u_char | |
11742 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
11743 | { | |
11744 | struct bgp_node *rn; | |
11745 | struct prefix_ipv4 q; | |
11746 | struct peer *peer; | |
11747 | struct bgp_distance *bdistance; | |
11748 | struct access_list *alist; | |
11749 | struct bgp_static *bgp_static; | |
11750 | ||
11751 | if (! bgp) | |
11752 | return 0; | |
11753 | ||
11754 | if (p->family != AF_INET) | |
11755 | return 0; | |
11756 | ||
11757 | peer = rinfo->peer; | |
11758 | ||
11759 | if (peer->su.sa.sa_family != AF_INET) | |
11760 | return 0; | |
11761 | ||
11762 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
11763 | q.family = AF_INET; | |
11764 | q.prefix = peer->su.sin.sin_addr; | |
11765 | q.prefixlen = IPV4_MAX_BITLEN; | |
11766 | ||
11767 | /* Check source address. */ | |
11768 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
11769 | if (rn) | |
11770 | { | |
11771 | bdistance = rn->info; | |
11772 | bgp_unlock_node (rn); | |
11773 | ||
11774 | if (bdistance->access_list) | |
11775 | { | |
11776 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
11777 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
11778 | return bdistance->distance; | |
11779 | } | |
11780 | else | |
11781 | return bdistance->distance; | |
11782 | } | |
11783 | ||
11784 | /* Backdoor check. */ | |
11785 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
11786 | if (rn) | |
11787 | { | |
11788 | bgp_static = rn->info; | |
11789 | bgp_unlock_node (rn); | |
11790 | ||
11791 | if (bgp_static->backdoor) | |
11792 | { | |
11793 | if (bgp->distance_local) | |
11794 | return bgp->distance_local; | |
11795 | else | |
11796 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11797 | } | |
11798 | } | |
11799 | ||
6d85b15b | 11800 | if (peer->sort == BGP_PEER_EBGP) |
718e3744 | 11801 | { |
11802 | if (bgp->distance_ebgp) | |
11803 | return bgp->distance_ebgp; | |
11804 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
11805 | } | |
11806 | else | |
11807 | { | |
11808 | if (bgp->distance_ibgp) | |
11809 | return bgp->distance_ibgp; | |
11810 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11811 | } | |
11812 | } | |
11813 | ||
11814 | DEFUN (bgp_distance, | |
11815 | bgp_distance_cmd, | |
11816 | "distance bgp <1-255> <1-255> <1-255>", | |
11817 | "Define an administrative distance\n" | |
11818 | "BGP distance\n" | |
11819 | "Distance for routes external to the AS\n" | |
11820 | "Distance for routes internal to the AS\n" | |
11821 | "Distance for local routes\n") | |
11822 | { | |
11823 | struct bgp *bgp; | |
11824 | ||
11825 | bgp = vty->index; | |
11826 | ||
11827 | bgp->distance_ebgp = atoi (argv[0]); | |
11828 | bgp->distance_ibgp = atoi (argv[1]); | |
11829 | bgp->distance_local = atoi (argv[2]); | |
11830 | return CMD_SUCCESS; | |
11831 | } | |
11832 | ||
11833 | DEFUN (no_bgp_distance, | |
11834 | no_bgp_distance_cmd, | |
11835 | "no distance bgp <1-255> <1-255> <1-255>", | |
11836 | NO_STR | |
11837 | "Define an administrative distance\n" | |
11838 | "BGP distance\n" | |
11839 | "Distance for routes external to the AS\n" | |
11840 | "Distance for routes internal to the AS\n" | |
11841 | "Distance for local routes\n") | |
11842 | { | |
11843 | struct bgp *bgp; | |
11844 | ||
11845 | bgp = vty->index; | |
11846 | ||
11847 | bgp->distance_ebgp= 0; | |
11848 | bgp->distance_ibgp = 0; | |
11849 | bgp->distance_local = 0; | |
11850 | return CMD_SUCCESS; | |
11851 | } | |
11852 | ||
11853 | ALIAS (no_bgp_distance, | |
11854 | no_bgp_distance2_cmd, | |
11855 | "no distance bgp", | |
11856 | NO_STR | |
11857 | "Define an administrative distance\n" | |
11858 | "BGP distance\n") | |
11859 | ||
11860 | DEFUN (bgp_distance_source, | |
11861 | bgp_distance_source_cmd, | |
11862 | "distance <1-255> A.B.C.D/M", | |
11863 | "Define an administrative distance\n" | |
11864 | "Administrative distance\n" | |
11865 | "IP source prefix\n") | |
11866 | { | |
11867 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
11868 | return CMD_SUCCESS; | |
11869 | } | |
11870 | ||
11871 | DEFUN (no_bgp_distance_source, | |
11872 | no_bgp_distance_source_cmd, | |
11873 | "no distance <1-255> A.B.C.D/M", | |
11874 | NO_STR | |
11875 | "Define an administrative distance\n" | |
11876 | "Administrative distance\n" | |
11877 | "IP source prefix\n") | |
11878 | { | |
11879 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
11880 | return CMD_SUCCESS; | |
11881 | } | |
11882 | ||
11883 | DEFUN (bgp_distance_source_access_list, | |
11884 | bgp_distance_source_access_list_cmd, | |
11885 | "distance <1-255> A.B.C.D/M WORD", | |
11886 | "Define an administrative distance\n" | |
11887 | "Administrative distance\n" | |
11888 | "IP source prefix\n" | |
11889 | "Access list name\n") | |
11890 | { | |
11891 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
11892 | return CMD_SUCCESS; | |
11893 | } | |
11894 | ||
11895 | DEFUN (no_bgp_distance_source_access_list, | |
11896 | no_bgp_distance_source_access_list_cmd, | |
11897 | "no distance <1-255> A.B.C.D/M WORD", | |
11898 | NO_STR | |
11899 | "Define an administrative distance\n" | |
11900 | "Administrative distance\n" | |
11901 | "IP source prefix\n" | |
11902 | "Access list name\n") | |
11903 | { | |
11904 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
11905 | return CMD_SUCCESS; | |
11906 | } | |
11907 | \f | |
11908 | DEFUN (bgp_damp_set, | |
11909 | bgp_damp_set_cmd, | |
11910 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11911 | "BGP Specific commands\n" | |
11912 | "Enable route-flap dampening\n" | |
11913 | "Half-life time for the penalty\n" | |
11914 | "Value to start reusing a route\n" | |
11915 | "Value to start suppressing a route\n" | |
11916 | "Maximum duration to suppress a stable route\n") | |
11917 | { | |
11918 | struct bgp *bgp; | |
11919 | int half = DEFAULT_HALF_LIFE * 60; | |
11920 | int reuse = DEFAULT_REUSE; | |
11921 | int suppress = DEFAULT_SUPPRESS; | |
11922 | int max = 4 * half; | |
11923 | ||
11924 | if (argc == 4) | |
11925 | { | |
11926 | half = atoi (argv[0]) * 60; | |
11927 | reuse = atoi (argv[1]); | |
11928 | suppress = atoi (argv[2]); | |
11929 | max = atoi (argv[3]) * 60; | |
11930 | } | |
11931 | else if (argc == 1) | |
11932 | { | |
11933 | half = atoi (argv[0]) * 60; | |
11934 | max = 4 * half; | |
11935 | } | |
11936 | ||
11937 | bgp = vty->index; | |
11938 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), | |
11939 | half, reuse, suppress, max); | |
11940 | } | |
11941 | ||
11942 | ALIAS (bgp_damp_set, | |
11943 | bgp_damp_set2_cmd, | |
11944 | "bgp dampening <1-45>", | |
11945 | "BGP Specific commands\n" | |
11946 | "Enable route-flap dampening\n" | |
11947 | "Half-life time for the penalty\n") | |
11948 | ||
11949 | ALIAS (bgp_damp_set, | |
11950 | bgp_damp_set3_cmd, | |
11951 | "bgp dampening", | |
11952 | "BGP Specific commands\n" | |
11953 | "Enable route-flap dampening\n") | |
11954 | ||
11955 | DEFUN (bgp_damp_unset, | |
11956 | bgp_damp_unset_cmd, | |
11957 | "no bgp dampening", | |
11958 | NO_STR | |
11959 | "BGP Specific commands\n" | |
11960 | "Enable route-flap dampening\n") | |
11961 | { | |
11962 | struct bgp *bgp; | |
11963 | ||
11964 | bgp = vty->index; | |
11965 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
11966 | } | |
11967 | ||
11968 | ALIAS (bgp_damp_unset, | |
11969 | bgp_damp_unset2_cmd, | |
11970 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11971 | NO_STR | |
11972 | "BGP Specific commands\n" | |
11973 | "Enable route-flap dampening\n" | |
11974 | "Half-life time for the penalty\n" | |
11975 | "Value to start reusing a route\n" | |
11976 | "Value to start suppressing a route\n" | |
11977 | "Maximum duration to suppress a stable route\n") | |
11978 | ||
11979 | DEFUN (show_ip_bgp_dampened_paths, | |
11980 | show_ip_bgp_dampened_paths_cmd, | |
11981 | "show ip bgp dampened-paths", | |
11982 | SHOW_STR | |
11983 | IP_STR | |
11984 | BGP_STR | |
11985 | "Display paths suppressed due to dampening\n") | |
11986 | { | |
5a646650 | 11987 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
11988 | NULL); | |
718e3744 | 11989 | } |
11990 | ||
11991 | DEFUN (show_ip_bgp_flap_statistics, | |
11992 | show_ip_bgp_flap_statistics_cmd, | |
11993 | "show ip bgp flap-statistics", | |
11994 | SHOW_STR | |
11995 | IP_STR | |
11996 | BGP_STR | |
11997 | "Display flap statistics of routes\n") | |
11998 | { | |
5a646650 | 11999 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
12000 | bgp_show_type_flap_statistics, NULL); | |
718e3744 | 12001 | } |
12002 | \f | |
12003 | /* Display specified route of BGP table. */ | |
94f2b392 | 12004 | static int |
fd79ac91 | 12005 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
12006 | const char *ip_str, afi_t afi, safi_t safi, | |
12007 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 12008 | { |
12009 | int ret; | |
12010 | struct prefix match; | |
12011 | struct bgp_node *rn; | |
12012 | struct bgp_node *rm; | |
12013 | struct bgp_info *ri; | |
12014 | struct bgp_info *ri_temp; | |
12015 | struct bgp *bgp; | |
12016 | struct bgp_table *table; | |
12017 | ||
12018 | /* BGP structure lookup. */ | |
12019 | if (view_name) | |
12020 | { | |
12021 | bgp = bgp_lookup_by_name (view_name); | |
12022 | if (bgp == NULL) | |
12023 | { | |
12024 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
12025 | return CMD_WARNING; | |
12026 | } | |
12027 | } | |
12028 | else | |
12029 | { | |
12030 | bgp = bgp_get_default (); | |
12031 | if (bgp == NULL) | |
12032 | { | |
12033 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
12034 | return CMD_WARNING; | |
12035 | } | |
12036 | } | |
12037 | ||
12038 | /* Check IP address argument. */ | |
12039 | ret = str2prefix (ip_str, &match); | |
12040 | if (! ret) | |
12041 | { | |
12042 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
12043 | return CMD_WARNING; | |
12044 | } | |
12045 | ||
12046 | match.family = afi2family (afi); | |
12047 | ||
12048 | if (safi == SAFI_MPLS_VPN) | |
12049 | { | |
12050 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) | |
12051 | { | |
12052 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
12053 | continue; | |
12054 | ||
12055 | if ((table = rn->info) != NULL) | |
12056 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
12057 | { |
12058 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
12059 | { | |
12060 | ri = rm->info; | |
12061 | while (ri) | |
12062 | { | |
12063 | if (ri->extra && ri->extra->damp_info) | |
12064 | { | |
12065 | ri_temp = ri->next; | |
12066 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
12067 | ri = ri_temp; | |
12068 | } | |
12069 | else | |
12070 | ri = ri->next; | |
12071 | } | |
12072 | } | |
12073 | ||
12074 | bgp_unlock_node (rm); | |
12075 | } | |
718e3744 | 12076 | } |
12077 | } | |
12078 | else | |
12079 | { | |
12080 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
12081 | { |
12082 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
12083 | { | |
12084 | ri = rn->info; | |
12085 | while (ri) | |
12086 | { | |
12087 | if (ri->extra && ri->extra->damp_info) | |
12088 | { | |
12089 | ri_temp = ri->next; | |
12090 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
12091 | ri = ri_temp; | |
12092 | } | |
12093 | else | |
12094 | ri = ri->next; | |
12095 | } | |
12096 | } | |
12097 | ||
12098 | bgp_unlock_node (rn); | |
12099 | } | |
718e3744 | 12100 | } |
12101 | ||
12102 | return CMD_SUCCESS; | |
12103 | } | |
12104 | ||
12105 | DEFUN (clear_ip_bgp_dampening, | |
12106 | clear_ip_bgp_dampening_cmd, | |
12107 | "clear ip bgp dampening", | |
12108 | CLEAR_STR | |
12109 | IP_STR | |
12110 | BGP_STR | |
12111 | "Clear route flap dampening information\n") | |
12112 | { | |
12113 | bgp_damp_info_clean (); | |
12114 | return CMD_SUCCESS; | |
12115 | } | |
12116 | ||
12117 | DEFUN (clear_ip_bgp_dampening_prefix, | |
12118 | clear_ip_bgp_dampening_prefix_cmd, | |
12119 | "clear ip bgp dampening A.B.C.D/M", | |
12120 | CLEAR_STR | |
12121 | IP_STR | |
12122 | BGP_STR | |
12123 | "Clear route flap dampening information\n" | |
12124 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
12125 | { | |
12126 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
12127 | SAFI_UNICAST, NULL, 1); | |
12128 | } | |
12129 | ||
12130 | DEFUN (clear_ip_bgp_dampening_address, | |
12131 | clear_ip_bgp_dampening_address_cmd, | |
12132 | "clear ip bgp dampening A.B.C.D", | |
12133 | CLEAR_STR | |
12134 | IP_STR | |
12135 | BGP_STR | |
12136 | "Clear route flap dampening information\n" | |
12137 | "Network to clear damping information\n") | |
12138 | { | |
12139 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
12140 | SAFI_UNICAST, NULL, 0); | |
12141 | } | |
12142 | ||
12143 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
12144 | clear_ip_bgp_dampening_address_mask_cmd, | |
12145 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
12146 | CLEAR_STR | |
12147 | IP_STR | |
12148 | BGP_STR | |
12149 | "Clear route flap dampening information\n" | |
12150 | "Network to clear damping information\n" | |
12151 | "Network mask\n") | |
12152 | { | |
12153 | int ret; | |
12154 | char prefix_str[BUFSIZ]; | |
12155 | ||
12156 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
12157 | if (! ret) | |
12158 | { | |
12159 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
12160 | return CMD_WARNING; | |
12161 | } | |
12162 | ||
12163 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
12164 | SAFI_UNICAST, NULL, 0); | |
12165 | } | |
12166 | \f | |
94f2b392 | 12167 | static int |
718e3744 | 12168 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
12169 | afi_t afi, safi_t safi, int *write) | |
12170 | { | |
12171 | struct bgp_node *prn; | |
12172 | struct bgp_node *rn; | |
12173 | struct bgp_table *table; | |
12174 | struct prefix *p; | |
12175 | struct prefix_rd *prd; | |
12176 | struct bgp_static *bgp_static; | |
12177 | u_int32_t label; | |
12178 | char buf[SU_ADDRSTRLEN]; | |
12179 | char rdbuf[RD_ADDRSTRLEN]; | |
12180 | ||
12181 | /* Network configuration. */ | |
12182 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
12183 | if ((table = prn->info) != NULL) | |
12184 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
12185 | if ((bgp_static = rn->info) != NULL) | |
12186 | { | |
12187 | p = &rn->p; | |
12188 | prd = (struct prefix_rd *) &prn->p; | |
12189 | ||
12190 | /* "address-family" display. */ | |
12191 | bgp_config_write_family_header (vty, afi, safi, write); | |
12192 | ||
12193 | /* "network" configuration display. */ | |
12194 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
12195 | label = decode_label (bgp_static->tag); | |
12196 | ||
12197 | vty_out (vty, " network %s/%d rd %s tag %d", | |
12198 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12199 | p->prefixlen, | |
12200 | rdbuf, label); | |
12201 | vty_out (vty, "%s", VTY_NEWLINE); | |
12202 | } | |
12203 | return 0; | |
12204 | } | |
12205 | ||
12206 | /* Configuration of static route announcement and aggregate | |
12207 | information. */ | |
12208 | int | |
12209 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
12210 | afi_t afi, safi_t safi, int *write) | |
12211 | { | |
12212 | struct bgp_node *rn; | |
12213 | struct prefix *p; | |
12214 | struct bgp_static *bgp_static; | |
12215 | struct bgp_aggregate *bgp_aggregate; | |
12216 | char buf[SU_ADDRSTRLEN]; | |
12217 | ||
12218 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
12219 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); | |
12220 | ||
12221 | /* Network configuration. */ | |
12222 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
12223 | if ((bgp_static = rn->info) != NULL) | |
12224 | { | |
12225 | p = &rn->p; | |
12226 | ||
12227 | /* "address-family" display. */ | |
12228 | bgp_config_write_family_header (vty, afi, safi, write); | |
12229 | ||
12230 | /* "network" configuration display. */ | |
12231 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
12232 | { | |
12233 | u_int32_t destination; | |
12234 | struct in_addr netmask; | |
12235 | ||
12236 | destination = ntohl (p->u.prefix4.s_addr); | |
12237 | masklen2ip (p->prefixlen, &netmask); | |
12238 | vty_out (vty, " network %s", | |
12239 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); | |
12240 | ||
12241 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
12242 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
12243 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
12244 | || p->u.prefix4.s_addr == 0) | |
12245 | { | |
12246 | /* Natural mask is not display. */ | |
12247 | } | |
12248 | else | |
12249 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
12250 | } | |
12251 | else | |
12252 | { | |
12253 | vty_out (vty, " network %s/%d", | |
12254 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12255 | p->prefixlen); | |
12256 | } | |
12257 | ||
12258 | if (bgp_static->rmap.name) | |
12259 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
12260 | else |
12261 | { | |
12262 | if (bgp_static->backdoor) | |
12263 | vty_out (vty, " backdoor"); | |
41367172 | 12264 | } |
718e3744 | 12265 | |
12266 | vty_out (vty, "%s", VTY_NEWLINE); | |
12267 | } | |
12268 | ||
12269 | /* Aggregate-address configuration. */ | |
12270 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
12271 | if ((bgp_aggregate = rn->info) != NULL) | |
12272 | { | |
12273 | p = &rn->p; | |
12274 | ||
12275 | /* "address-family" display. */ | |
12276 | bgp_config_write_family_header (vty, afi, safi, write); | |
12277 | ||
12278 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
12279 | { | |
12280 | struct in_addr netmask; | |
12281 | ||
12282 | masklen2ip (p->prefixlen, &netmask); | |
12283 | vty_out (vty, " aggregate-address %s %s", | |
12284 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12285 | inet_ntoa (netmask)); | |
12286 | } | |
12287 | else | |
12288 | { | |
12289 | vty_out (vty, " aggregate-address %s/%d", | |
12290 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12291 | p->prefixlen); | |
12292 | } | |
12293 | ||
12294 | if (bgp_aggregate->as_set) | |
12295 | vty_out (vty, " as-set"); | |
12296 | ||
12297 | if (bgp_aggregate->summary_only) | |
12298 | vty_out (vty, " summary-only"); | |
12299 | ||
12300 | vty_out (vty, "%s", VTY_NEWLINE); | |
12301 | } | |
12302 | ||
12303 | return 0; | |
12304 | } | |
12305 | ||
12306 | int | |
12307 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
12308 | { | |
12309 | struct bgp_node *rn; | |
12310 | struct bgp_distance *bdistance; | |
12311 | ||
12312 | /* Distance configuration. */ | |
12313 | if (bgp->distance_ebgp | |
12314 | && bgp->distance_ibgp | |
12315 | && bgp->distance_local | |
12316 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
12317 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
12318 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
12319 | vty_out (vty, " distance bgp %d %d %d%s", | |
12320 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
12321 | VTY_NEWLINE); | |
12322 | ||
12323 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
12324 | if ((bdistance = rn->info) != NULL) | |
12325 | { | |
12326 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
12327 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
12328 | bdistance->access_list ? bdistance->access_list : "", | |
12329 | VTY_NEWLINE); | |
12330 | } | |
12331 | ||
12332 | return 0; | |
12333 | } | |
12334 | ||
12335 | /* Allocate routing table structure and install commands. */ | |
12336 | void | |
66e5cd87 | 12337 | bgp_route_init (void) |
718e3744 | 12338 | { |
12339 | /* Init BGP distance table. */ | |
64e580a7 | 12340 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 12341 | |
12342 | /* IPv4 BGP commands. */ | |
12343 | install_element (BGP_NODE, &bgp_network_cmd); | |
12344 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
12345 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
12346 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
12347 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
12348 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
12349 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
12350 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
12351 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
12352 | install_element (BGP_NODE, &no_bgp_network_cmd); | |
12353 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
12354 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
12355 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
12356 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
12357 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
12358 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
12359 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
12360 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
12361 | ||
12362 | install_element (BGP_NODE, &aggregate_address_cmd); | |
12363 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
12364 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
12365 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
12366 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
12367 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
12368 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
12369 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12370 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
12371 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12372 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
12373 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
12374 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
12375 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12376 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12377 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
12378 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12379 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12380 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12381 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12382 | ||
12383 | /* IPv4 unicast configuration. */ | |
12384 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); | |
12385 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
12386 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
12387 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
12388 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
12389 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 12390 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
718e3744 | 12391 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
12392 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
12393 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
12394 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
12395 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 12396 | |
718e3744 | 12397 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
12398 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
12399 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
12400 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
12401 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
12402 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
12403 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
12404 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12405 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
12406 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12407 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
12408 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
12409 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
12410 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12411 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12412 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
12413 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12414 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12415 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12416 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12417 | ||
12418 | /* IPv4 multicast configuration. */ | |
12419 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); | |
12420 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
12421 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
12422 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
12423 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
12424 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
12425 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); | |
12426 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
12427 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
12428 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
12429 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
12430 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
12431 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); | |
12432 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
12433 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
12434 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
12435 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
12436 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
12437 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
12438 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12439 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
12440 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12441 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
12442 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
12443 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
12444 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12445 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12446 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
12447 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12448 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12449 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12450 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12451 | ||
12452 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
12453 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); | |
95cbbd2a | 12454 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 12455 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
12456 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12457 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 12458 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
12459 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
12460 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
12461 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12462 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
718e3744 | 12463 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12464 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12465 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); | |
12466 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); | |
12467 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); | |
12468 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); | |
12469 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
12470 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
12471 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
12472 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
12473 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
12474 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
12475 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
12476 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
12477 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
12478 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
12479 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
12480 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
12481 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
12482 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
12483 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
12484 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12485 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12486 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12487 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12488 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12489 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12490 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12491 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12492 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
718e3744 | 12493 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
12494 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
12495 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
12496 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
12497 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12498 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12499 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12500 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12501 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
12502 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
12503 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
12504 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
12505 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
12506 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
12507 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
12508 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
12509 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
12510 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
95cbbd2a | 12511 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 12512 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
12513 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
12514 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
12515 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
12516 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); | |
12517 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); | |
12518 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); | |
12519 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); | |
12520 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
12521 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); | |
12522 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
12523 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
12524 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
12525 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); | |
12526 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
12527 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 12528 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
95cbbd2a | 12529 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12530 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
95cbbd2a | 12531 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12532 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12533 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
2a71e9ce TP |
12534 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
12535 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 12536 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
95cbbd2a | 12537 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12538 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12539 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12540 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12541 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12542 | |
12543 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
12544 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
12545 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12546 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
62687ff1 PJ |
12547 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
12548 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
12549 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12550 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
62687ff1 PJ |
12551 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12552 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12553 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); | |
12554 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); | |
12555 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); | |
12556 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
12557 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
12558 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
12559 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12560 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12561 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12562 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12563 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12564 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12565 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12566 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12567 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
62687ff1 PJ |
12568 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
12569 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
12570 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
12571 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
12572 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12573 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12574 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12575 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12576 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); | |
95cbbd2a | 12577 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
62687ff1 | 12578 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12579 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
62687ff1 | 12580 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12581 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
62687ff1 | 12582 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12583 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
718e3744 | 12584 | |
12585 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
12586 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); | |
95cbbd2a | 12587 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 12588 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
12589 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12590 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 12591 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
12592 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
12593 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
12594 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12595 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
718e3744 | 12596 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12597 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12598 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); | |
12599 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); | |
12600 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); | |
12601 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); | |
12602 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
12603 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
12604 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
12605 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
12606 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
12607 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
12608 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
12609 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
12610 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
12611 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
12612 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
12613 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
12614 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
12615 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
12616 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
12617 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12618 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12619 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12620 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12621 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12622 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12623 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12624 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12625 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
718e3744 | 12626 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
12627 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
12628 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
12629 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
12630 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12631 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12632 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12633 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12634 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
12635 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
12636 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
12637 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
12638 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
12639 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
12640 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
12641 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
12642 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
12643 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
95cbbd2a | 12644 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 12645 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
12646 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
12647 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
12648 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
12649 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); | |
12650 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); | |
12651 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); | |
12652 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); | |
12653 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
12654 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); | |
12655 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
12656 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
12657 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
12658 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); | |
12659 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
12660 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 12661 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
95cbbd2a | 12662 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12663 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
95cbbd2a | 12664 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12665 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12666 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
2a71e9ce TP |
12667 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
12668 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 12669 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
95cbbd2a | 12670 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12671 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12672 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12673 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12674 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
718e3744 | 12675 | |
12676 | /* BGP dampening clear commands */ | |
12677 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
12678 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
12679 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
12680 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
12681 | ||
ff7924f6 PJ |
12682 | /* prefix count */ |
12683 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
12684 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); | |
12685 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 12686 | #ifdef HAVE_IPV6 |
ff7924f6 PJ |
12687 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
12688 | ||
718e3744 | 12689 | /* New config IPv6 BGP commands. */ |
12690 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); | |
12691 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
12692 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); | |
12693 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
12694 | ||
12695 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
12696 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
12697 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
12698 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
73bfe0bd B |
12699 | |
12700 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); | |
12701 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); | |
718e3744 | 12702 | |
12703 | /* Old config IPv6 BGP commands. */ | |
12704 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
12705 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
12706 | ||
12707 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
12708 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
12709 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
12710 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
12711 | ||
12712 | install_element (VIEW_NODE, &show_bgp_cmd); | |
12713 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 12714 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 12715 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
12716 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12717 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
718e3744 | 12718 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
12719 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12720 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 12721 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
12722 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
12723 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
12724 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12725 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
12726 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12727 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
12728 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
12729 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
12730 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
12731 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
12732 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
12733 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
12734 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
12735 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
12736 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
12737 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
12738 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
12739 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
12740 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12741 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
12742 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12743 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
12744 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12745 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
12746 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12747 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
12748 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
12749 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
12750 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12751 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
12752 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12753 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12754 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12755 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12756 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12757 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
12758 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12759 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12760 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12761 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
12762 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12763 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
12764 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12765 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
95cbbd2a | 12766 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12767 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
95cbbd2a | 12768 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12769 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12770 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
bb46e94f | 12771 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
12772 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); | |
12773 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); | |
12774 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); | |
12775 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); | |
12776 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12777 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12778 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12779 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12780 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12781 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12782 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12783 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12784 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12785 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12786 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12787 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12788 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12789 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
95cbbd2a | 12790 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12791 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12792 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12793 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12794 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12795 | |
12796 | /* Restricted: | |
12797 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
12798 | */ | |
12799 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
12800 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12801 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
62687ff1 PJ |
12802 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
12803 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12804 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
62687ff1 PJ |
12805 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
12806 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
12807 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
12808 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
12809 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
12810 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
12811 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
12812 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
12813 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
12814 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12815 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
12816 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12817 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
12818 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12819 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
12820 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12821 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); | |
95cbbd2a | 12822 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
62687ff1 | 12823 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12824 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12825 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
12826 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); | |
12827 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); | |
12828 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12829 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12830 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12831 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); | |
95cbbd2a | 12832 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
62687ff1 | 12833 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12834 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
718e3744 | 12835 | |
12836 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
12837 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 12838 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 12839 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
12840 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12841 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
718e3744 | 12842 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
12843 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12844 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 12845 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
12846 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
12847 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
12848 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12849 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
12850 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12851 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
12852 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
12853 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
12854 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
12855 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
12856 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
12857 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
12858 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
12859 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
12860 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
12861 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
12862 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
12863 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
12864 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12865 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
12866 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12867 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
12868 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12869 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
12870 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12871 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
12872 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
12873 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
12874 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12875 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
12876 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12877 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12878 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12879 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12880 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12881 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
12882 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12883 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12884 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12885 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
12886 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12887 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
12888 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12889 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
95cbbd2a | 12890 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12891 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
95cbbd2a | 12892 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12893 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12894 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
bb46e94f | 12895 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
12896 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); | |
12897 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); | |
12898 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); | |
12899 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); | |
12900 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12901 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12902 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12903 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12904 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12905 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12906 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12907 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12908 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12909 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12910 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12911 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12912 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12913 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
95cbbd2a | 12914 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12915 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12916 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12917 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12918 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
2815e61f PJ |
12919 | |
12920 | /* Statistics */ | |
12921 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
12922 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); | |
12923 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); | |
12924 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); | |
12925 | ||
718e3744 | 12926 | /* old command */ |
12927 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
12928 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
12929 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
12930 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
12931 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12932 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12933 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
12934 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
12935 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
12936 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
12937 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
12938 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12939 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12940 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12941 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12942 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
12943 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12944 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12945 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
12946 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
12947 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12948 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12949 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12950 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12951 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12952 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
12953 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
12954 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
12955 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
12956 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12957 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12958 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12959 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12960 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12961 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12962 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 12963 | |
718e3744 | 12964 | /* old command */ |
12965 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
12966 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
12967 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
12968 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
12969 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12970 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12971 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
12972 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
12973 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
12974 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
12975 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
12976 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12977 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12978 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12979 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12980 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
12981 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12982 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12983 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
12984 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
12985 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12986 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12987 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12988 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12989 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12990 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
12991 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
12992 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
12993 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
12994 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12995 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12996 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12997 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12998 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12999 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
13000 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
13001 | ||
13002 | /* old command */ | |
13003 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
13004 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
13005 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
13006 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
13007 | ||
13008 | /* old command */ | |
13009 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
13010 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
13011 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
13012 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
13013 | ||
13014 | /* old command */ | |
13015 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
13016 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
13017 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
13018 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
13019 | #endif /* HAVE_IPV6 */ | |
13020 | ||
13021 | install_element (BGP_NODE, &bgp_distance_cmd); | |
13022 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
13023 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
13024 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
13025 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
13026 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
13027 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
13028 | ||
13029 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
13030 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
13031 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
13032 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
13033 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
13034 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); | |
13035 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
13036 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
13037 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
13038 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
c8f3fe30 PJ |
13039 | |
13040 | /* Deprecated AS-Pathlimit commands */ | |
13041 | install_element (BGP_NODE, &bgp_network_ttl_cmd); | |
13042 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); | |
13043 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); | |
13044 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); | |
13045 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
13046 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
13047 | ||
13048 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); | |
13049 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); | |
13050 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
13051 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
13052 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
13053 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
13054 | ||
13055 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); | |
13056 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); | |
13057 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); | |
13058 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); | |
13059 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
13060 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
13061 | ||
13062 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); | |
13063 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); | |
13064 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
13065 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
13066 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
13067 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
13068 | ||
13069 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); | |
13070 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); | |
13071 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); | |
13072 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); | |
13073 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
13074 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
13075 | ||
13076 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); | |
13077 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); | |
13078 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
13079 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
13080 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
13081 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
3bde17f1 PJ |
13082 | |
13083 | #ifdef HAVE_IPV6 | |
c8f3fe30 PJ |
13084 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
13085 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); | |
3bde17f1 | 13086 | #endif |
718e3744 | 13087 | } |
228da428 CC |
13088 | |
13089 | void | |
13090 | bgp_route_finish (void) | |
13091 | { | |
13092 | bgp_table_unlock (bgp_distance_table); | |
13093 | bgp_distance_table = NULL; | |
13094 | } |