]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * OSPF inter-area routing. | |
3 | * Copyright (C) 1999, 2000 Alex Zinin, Toshiaki Takada | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | ||
24 | #include <zebra.h> | |
25 | ||
26 | #include "thread.h" | |
27 | #include "memory.h" | |
28 | #include "hash.h" | |
29 | #include "linklist.h" | |
30 | #include "prefix.h" | |
31 | #include "table.h" | |
32 | #include "log.h" | |
33 | ||
34 | #include "ospfd/ospfd.h" | |
35 | #include "ospfd/ospf_interface.h" | |
36 | #include "ospfd/ospf_ism.h" | |
37 | #include "ospfd/ospf_asbr.h" | |
38 | #include "ospfd/ospf_lsa.h" | |
39 | #include "ospfd/ospf_lsdb.h" | |
40 | #include "ospfd/ospf_neighbor.h" | |
41 | #include "ospfd/ospf_nsm.h" | |
42 | #include "ospfd/ospf_spf.h" | |
43 | #include "ospfd/ospf_route.h" | |
44 | #include "ospfd/ospf_ase.h" | |
45 | #include "ospfd/ospf_abr.h" | |
46 | #include "ospfd/ospf_ia.h" | |
47 | #include "ospfd/ospf_dump.h" | |
48 | ||
4dadc291 | 49 | static struct ospf_route * |
718e3744 | 50 | ospf_find_abr_route (struct route_table *rtrs, |
51 | struct prefix_ipv4 *abr, | |
52 | struct ospf_area *area) | |
53 | { | |
54 | struct route_node *rn; | |
55 | struct ospf_route *or; | |
52dc7ee6 | 56 | struct listnode *node; |
718e3744 | 57 | |
58 | if ((rn = route_node_lookup (rtrs, (struct prefix *) abr)) == NULL) | |
59 | return NULL; | |
60 | ||
61 | route_unlock_node (rn); | |
62 | ||
1eb8ef25 | 63 | for (ALL_LIST_ELEMENTS_RO ((struct list *) rn->info, node, or)) |
64 | if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id) | |
65 | && (or->u.std.flags & ROUTER_LSA_BORDER)) | |
66 | return or; | |
718e3744 | 67 | |
68 | return NULL; | |
69 | } | |
70 | ||
4dadc291 | 71 | static void |
96735eea | 72 | ospf_ia_network_route (struct ospf *ospf, struct route_table *rt, |
73 | struct prefix_ipv4 *p, struct ospf_route *new_or, | |
74 | struct ospf_route *abr_or) | |
718e3744 | 75 | { |
76 | struct route_node *rn1; | |
77 | struct ospf_route *or; | |
78 | ||
79 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 80 | zlog_debug ("ospf_ia_network_route(): processing summary route to %s/%d", |
718e3744 | 81 | inet_ntoa (p->prefix), p->prefixlen); |
82 | ||
83 | /* Find a route to the same dest */ | |
84 | if ((rn1 = route_node_lookup (rt, (struct prefix *) p))) | |
85 | { | |
86 | int res; | |
87 | ||
88 | route_unlock_node (rn1); | |
89 | ||
90 | if ((or = rn1->info)) | |
91 | { | |
92 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 93 | zlog_debug ("ospf_ia_network_route(): " |
718e3744 | 94 | "Found a route to the same network"); |
95 | /* Check the existing route. */ | |
96735eea | 96 | if ((res = ospf_route_cmp (ospf, new_or, or)) < 0) |
718e3744 | 97 | { |
98 | /* New route is better, so replace old one. */ | |
99 | ospf_route_subst (rn1, new_or, abr_or); | |
100 | } | |
101 | else if (res == 0) | |
102 | { | |
103 | /* New and old route are equal, so next hops can be added. */ | |
104 | route_lock_node (rn1); | |
96735eea | 105 | ospf_route_copy_nexthops (or, abr_or->paths); |
718e3744 | 106 | route_unlock_node (rn1); |
107 | ||
108 | /* new route can be deleted, because existing route has been updated. */ | |
109 | ospf_route_free (new_or); | |
110 | } | |
111 | else | |
112 | { | |
113 | /* New route is worse, so free it. */ | |
114 | ospf_route_free (new_or); | |
115 | return; | |
116 | } | |
117 | } /* if (or)*/ | |
118 | } /*if (rn1)*/ | |
119 | else | |
120 | { /* no route */ | |
121 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 122 | zlog_debug ("ospf_ia_network_route(): add new route to %s/%d", |
718e3744 | 123 | inet_ntoa (p->prefix), p->prefixlen); |
124 | ospf_route_add (rt, p, new_or, abr_or); | |
125 | } | |
126 | } | |
127 | ||
4dadc291 | 128 | static void |
96735eea | 129 | ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs, |
130 | struct prefix_ipv4 *p, | |
718e3744 | 131 | struct ospf_route *new_or, struct ospf_route *abr_or) |
132 | { | |
718e3744 | 133 | struct ospf_route *or = NULL; |
96735eea | 134 | struct route_node *rn; |
718e3744 | 135 | int ret; |
136 | ||
137 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 138 | zlog_debug ("ospf_ia_router_route(): considering %s/%d", |
718e3744 | 139 | inet_ntoa (p->prefix), p->prefixlen); |
140 | /* Find a route to the same dest */ | |
96735eea | 141 | rn = route_node_get (rtrs, (struct prefix *) p); |
718e3744 | 142 | |
143 | if (rn->info == NULL) | |
144 | /* This is a new route */ | |
145 | rn->info = list_new (); | |
146 | else | |
147 | { | |
148 | struct ospf_area *or_area; | |
96735eea | 149 | or_area = ospf_area_lookup_by_area_id (ospf, new_or->u.std.area_id); |
718e3744 | 150 | assert (or_area); |
151 | /* This is an additional route */ | |
152 | route_unlock_node (rn); | |
96735eea | 153 | or = ospf_find_asbr_route_through_area (rtrs, p, or_area); |
718e3744 | 154 | } |
155 | ||
156 | if (or) | |
157 | { | |
158 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 159 | zlog_debug ("ospf_ia_router_route(): " |
718e3744 | 160 | "a route to the same ABR through the same area exists"); |
161 | /* New route is better */ | |
96735eea | 162 | if ((ret = ospf_route_cmp (ospf, new_or, or)) < 0) |
718e3744 | 163 | { |
164 | listnode_delete (rn->info, or); | |
165 | ospf_route_free (or); | |
166 | /* proceed down */ | |
167 | } | |
168 | /* Routes are the same */ | |
169 | else if (ret == 0) | |
170 | { | |
171 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 172 | zlog_debug ("ospf_ia_router_route(): merging the new route"); |
718e3744 | 173 | |
96735eea | 174 | ospf_route_copy_nexthops (or, abr_or->paths); |
718e3744 | 175 | ospf_route_free (new_or); |
176 | return; | |
177 | } | |
178 | /* New route is worse */ | |
179 | else | |
180 | { | |
181 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 182 | zlog_debug ("ospf_ia_router_route(): skipping the new route"); |
718e3744 | 183 | ospf_route_free (new_or); |
184 | return; | |
185 | } | |
186 | } | |
187 | ||
96735eea | 188 | ospf_route_copy_nexthops (new_or, abr_or->paths); |
718e3744 | 189 | |
190 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 191 | zlog_debug ("ospf_ia_router_route(): adding the new route"); |
718e3744 | 192 | |
193 | listnode_add (rn->info, new_or); | |
194 | } | |
195 | ||
196 | \f | |
4dadc291 | 197 | static int |
96735eea | 198 | process_summary_lsa (struct ospf_area *area, struct route_table *rt, |
199 | struct route_table *rtrs, struct ospf_lsa *lsa) | |
718e3744 | 200 | { |
96735eea | 201 | struct ospf *ospf = area->ospf; |
718e3744 | 202 | struct ospf_area_range *range; |
203 | struct ospf_route *abr_or, *new_or; | |
204 | struct summary_lsa *sl; | |
205 | struct prefix_ipv4 p, abr; | |
206 | u_int32_t metric; | |
718e3744 | 207 | |
96735eea | 208 | if (lsa == NULL) |
718e3744 | 209 | return 0; |
210 | ||
96735eea | 211 | sl = (struct summary_lsa *) lsa->data; |
718e3744 | 212 | |
213 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 214 | zlog_debug ("process_summary_lsa(): LS ID: %s", inet_ntoa (sl->header.id)); |
718e3744 | 215 | |
216 | metric = GET_METRIC (sl->metric); | |
217 | ||
218 | if (metric == OSPF_LS_INFINITY) | |
219 | return 0; | |
220 | ||
96735eea | 221 | if (IS_LSA_MAXAGE (lsa)) |
718e3744 | 222 | return 0; |
223 | ||
96735eea | 224 | if (ospf_lsa_is_self_originated (area->ospf, lsa)) |
718e3744 | 225 | return 0; |
226 | ||
227 | p.family = AF_INET; | |
228 | p.prefix = sl->header.id; | |
229 | ||
230 | if (sl->header.type == OSPF_SUMMARY_LSA) | |
231 | p.prefixlen = ip_masklen (sl->mask); | |
232 | else | |
233 | p.prefixlen = IPV4_MAX_BITLEN; | |
234 | ||
235 | apply_mask_ipv4 (&p); | |
236 | ||
237 | if (sl->header.type == OSPF_SUMMARY_LSA && | |
96735eea | 238 | (range = ospf_area_range_match_any (ospf, &p)) && |
718e3744 | 239 | ospf_area_range_active (range)) |
240 | return 0; | |
241 | ||
05e85fa9 | 242 | /* XXX: This check seems dubious to me. If an ABR has already decided |
243 | * to consider summaries received in this area, then why would one wish | |
244 | * to exclude default? | |
245 | */ | |
246 | if (IS_OSPF_ABR(ospf) && | |
247 | ospf->abr_type != OSPF_ABR_STAND && | |
96735eea | 248 | area->external_routing != OSPF_AREA_DEFAULT && |
718e3744 | 249 | p.prefix.s_addr == OSPF_DEFAULT_DESTINATION && |
250 | p.prefixlen == 0) | |
251 | return 0; /* Ignore summary default from a stub area */ | |
252 | ||
253 | abr.family = AF_INET; | |
254 | abr.prefix = sl->header.adv_router; | |
255 | abr.prefixlen = IPV4_MAX_BITLEN; | |
256 | apply_mask_ipv4 (&abr); | |
257 | ||
96735eea | 258 | abr_or = ospf_find_abr_route (rtrs, &abr, area); |
718e3744 | 259 | |
260 | if (abr_or == NULL) | |
261 | return 0; | |
262 | ||
263 | new_or = ospf_route_new (); | |
264 | new_or->type = OSPF_DESTINATION_NETWORK; | |
265 | new_or->id = sl->header.id; | |
266 | new_or->mask = sl->mask; | |
267 | new_or->u.std.options = sl->header.options; | |
268 | new_or->u.std.origin = (struct lsa_header *) sl; | |
269 | new_or->cost = abr_or->cost + metric; | |
96735eea | 270 | new_or->u.std.area_id = area->area_id; |
96735eea | 271 | new_or->u.std.external_routing = area->external_routing; |
718e3744 | 272 | new_or->path_type = OSPF_PATH_INTER_AREA; |
273 | ||
274 | if (sl->header.type == OSPF_SUMMARY_LSA) | |
96735eea | 275 | ospf_ia_network_route (ospf, rt, &p, new_or, abr_or); |
718e3744 | 276 | else |
277 | { | |
278 | new_or->type = OSPF_DESTINATION_ROUTER; | |
279 | new_or->u.std.flags = ROUTER_LSA_EXTERNAL; | |
96735eea | 280 | ospf_ia_router_route (ospf, rtrs, &p, new_or, abr_or); |
718e3744 | 281 | } |
282 | ||
283 | return 0; | |
284 | } | |
285 | ||
4dadc291 | 286 | static void |
96735eea | 287 | ospf_examine_summaries (struct ospf_area *area, |
718e3744 | 288 | struct route_table *lsdb_rt, |
289 | struct route_table *rt, | |
290 | struct route_table *rtrs) | |
291 | { | |
96735eea | 292 | struct ospf_lsa *lsa; |
293 | struct route_node *rn; | |
294 | ||
295 | LSDB_LOOP (lsdb_rt, rn, lsa) | |
296 | process_summary_lsa (area, rt, rtrs, lsa); | |
718e3744 | 297 | } |
298 | ||
299 | int | |
300 | ospf_area_is_transit (struct ospf_area *area) | |
301 | { | |
302 | return (area->transit == OSPF_TRANSIT_TRUE) || | |
303 | ospf_full_virtual_nbrs(area); /* Cisco forgets to set the V-bit :( */ | |
304 | } | |
305 | ||
4dadc291 | 306 | static void |
96735eea | 307 | ospf_update_network_route (struct ospf *ospf, |
308 | struct route_table *rt, | |
718e3744 | 309 | struct route_table *rtrs, |
310 | struct summary_lsa *lsa, | |
311 | struct prefix_ipv4 *p, | |
312 | struct ospf_area *area) | |
313 | { | |
314 | struct route_node *rn; | |
315 | struct ospf_route *or, *abr_or, *new_or; | |
316 | struct prefix_ipv4 abr; | |
317 | u_int32_t cost; | |
318 | ||
319 | abr.family = AF_INET; | |
320 | abr.prefix =lsa->header.adv_router; | |
321 | abr.prefixlen = IPV4_MAX_BITLEN; | |
322 | apply_mask_ipv4 (&abr); | |
323 | ||
324 | abr_or = ospf_find_abr_route (rtrs, &abr, area); | |
325 | ||
326 | if (abr_or == NULL) | |
327 | { | |
328 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 329 | zlog_debug ("ospf_update_network_route(): can't find a route to the ABR"); |
718e3744 | 330 | return; |
331 | } | |
332 | ||
333 | cost = abr_or->cost + GET_METRIC (lsa->metric); | |
334 | ||
335 | rn = route_node_lookup (rt, (struct prefix *) p); | |
336 | ||
337 | if (! rn) | |
338 | { | |
96735eea | 339 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 340 | return; /* Standard ABR can update only already installed |
341 | backbone paths */ | |
342 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 343 | zlog_debug ("ospf_update_network_route(): " |
718e3744 | 344 | "Allowing Shortcut ABR to add new route"); |
345 | new_or = ospf_route_new (); | |
346 | new_or->type = OSPF_DESTINATION_NETWORK; | |
347 | new_or->id = lsa->header.id; | |
348 | new_or->mask = lsa->mask; | |
349 | new_or->u.std.options = lsa->header.options; | |
350 | new_or->u.std.origin = (struct lsa_header *) lsa; | |
351 | new_or->cost = cost; | |
352 | new_or->u.std.area_id = area->area_id; | |
718e3744 | 353 | new_or->u.std.external_routing = area->external_routing; |
718e3744 | 354 | new_or->path_type = OSPF_PATH_INTER_AREA; |
355 | ospf_route_add (rt, p, new_or, abr_or); | |
356 | ||
357 | return; | |
358 | } | |
359 | else | |
360 | { | |
361 | route_unlock_node (rn); | |
362 | if (rn->info == NULL) | |
363 | return; | |
364 | } | |
365 | ||
366 | or = rn->info; | |
367 | ||
368 | if (or->path_type != OSPF_PATH_INTRA_AREA && | |
369 | or->path_type != OSPF_PATH_INTER_AREA) | |
370 | { | |
371 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 372 | zlog_debug ("ospf_update_network_route(): ERR: path type is wrong"); |
718e3744 | 373 | return; |
374 | } | |
375 | ||
96735eea | 376 | if (ospf->abr_type == OSPF_ABR_SHORTCUT) |
718e3744 | 377 | { |
378 | if (or->path_type == OSPF_PATH_INTRA_AREA && | |
379 | !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) | |
380 | { | |
381 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 382 | zlog_debug ("ospf_update_network_route(): Shortcut: " |
718e3744 | 383 | "this intra-area path is not backbone"); |
384 | return; | |
385 | } | |
386 | } | |
387 | else /* Not Shortcut ABR */ | |
388 | { | |
389 | if (!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) | |
390 | { | |
391 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 392 | zlog_debug ("ospf_update_network_route(): " |
718e3744 | 393 | "route is not BB-associated"); |
394 | return; /* We can update only BB routes */ | |
395 | } | |
396 | } | |
397 | ||
398 | if (or->cost < cost) | |
399 | { | |
400 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 401 | zlog_debug ("ospf_update_network_route(): new route is worse"); |
718e3744 | 402 | return; |
403 | } | |
404 | ||
405 | if (or->cost == cost) | |
406 | { | |
407 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 408 | zlog_debug ("ospf_update_network_route(): " |
718e3744 | 409 | "new route is same distance, adding nexthops"); |
96735eea | 410 | ospf_route_copy_nexthops (or, abr_or->paths); |
718e3744 | 411 | } |
412 | ||
413 | if (or->cost > cost) | |
414 | { | |
415 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 416 | zlog_debug ("ospf_update_network_route(): " |
718e3744 | 417 | "new route is better, overriding nexthops"); |
96735eea | 418 | ospf_route_subst_nexthops (or, abr_or->paths); |
718e3744 | 419 | or->cost = cost; |
420 | ||
96735eea | 421 | if ((ospf->abr_type == OSPF_ABR_SHORTCUT) && |
718e3744 | 422 | !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) |
423 | { | |
424 | or->path_type = OSPF_PATH_INTER_AREA; | |
425 | or->u.std.area_id = area->area_id; | |
718e3744 | 426 | or->u.std.external_routing = area->external_routing; |
718e3744 | 427 | /* Note that we can do this only in Shortcut ABR mode, |
428 | because standard ABR must leave the route type and area | |
429 | unchanged | |
430 | */ | |
431 | } | |
432 | } | |
433 | } | |
434 | ||
4dadc291 | 435 | static void |
96735eea | 436 | ospf_update_router_route (struct ospf *ospf, |
437 | struct route_table *rtrs, | |
718e3744 | 438 | struct summary_lsa *lsa, |
439 | struct prefix_ipv4 *p, | |
440 | struct ospf_area *area) | |
441 | { | |
442 | struct ospf_route *or, *abr_or, *new_or; | |
443 | struct prefix_ipv4 abr; | |
444 | u_int32_t cost; | |
445 | ||
446 | abr.family = AF_INET; | |
447 | abr.prefix = lsa->header.adv_router; | |
448 | abr.prefixlen = IPV4_MAX_BITLEN; | |
449 | apply_mask_ipv4 (&abr); | |
450 | ||
451 | abr_or = ospf_find_abr_route (rtrs, &abr, area); | |
452 | ||
453 | if (abr_or == NULL) | |
454 | { | |
455 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 456 | zlog_debug ("ospf_update_router_route(): can't find a route to the ABR"); |
718e3744 | 457 | return; |
458 | } | |
459 | ||
460 | cost = abr_or->cost + GET_METRIC (lsa->metric); | |
461 | ||
462 | /* First try to find a backbone path, | |
463 | because standard ABR can update only BB-associated paths */ | |
464 | ||
96735eea | 465 | if ((ospf->backbone == NULL) && |
466 | (ospf->abr_type != OSPF_ABR_SHORTCUT)) | |
718e3744 | 467 | |
468 | /* no BB area, not Shortcut ABR, exiting */ | |
469 | return; | |
470 | ||
96735eea | 471 | or = ospf_find_asbr_route_through_area (rtrs, p, ospf->backbone); |
718e3744 | 472 | |
473 | if (or == NULL) | |
474 | { | |
96735eea | 475 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 476 | |
477 | /* route to ASBR through the BB not found | |
478 | the router is not Shortcut ABR, exiting */ | |
479 | ||
480 | return; | |
481 | else | |
482 | /* We're a Shortcut ABR*/ | |
483 | { | |
484 | /* Let it either add a new router or update the route | |
485 | through the same (non-BB) area. */ | |
486 | ||
487 | new_or = ospf_route_new (); | |
488 | new_or->type = OSPF_DESTINATION_ROUTER; | |
489 | new_or->id = lsa->header.id; | |
490 | new_or->mask = lsa->mask; | |
491 | new_or->u.std.options = lsa->header.options; | |
492 | new_or->u.std.origin = (struct lsa_header *)lsa; | |
493 | new_or->cost = cost; | |
494 | new_or->u.std.area_id = area->area_id; | |
718e3744 | 495 | new_or->u.std.external_routing = area->external_routing; |
718e3744 | 496 | new_or->path_type = OSPF_PATH_INTER_AREA; |
497 | new_or->u.std.flags = ROUTER_LSA_EXTERNAL; | |
96735eea | 498 | ospf_ia_router_route (ospf, rtrs, p, new_or, abr_or); |
718e3744 | 499 | |
500 | return; | |
501 | } | |
502 | } | |
503 | ||
504 | /* At this point the "or" is always bb-associated */ | |
505 | ||
506 | if (!(or->u.std.flags & ROUTER_LSA_EXTERNAL)) | |
507 | { | |
508 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 509 | zlog_debug ("ospf_upd_router_route(): the remote router is not an ASBR"); |
718e3744 | 510 | return; |
511 | } | |
512 | ||
513 | if (or->path_type != OSPF_PATH_INTRA_AREA && | |
514 | or->path_type != OSPF_PATH_INTER_AREA) | |
515 | return; | |
516 | ||
517 | if (or->cost < cost) | |
518 | return; | |
519 | ||
520 | else if (or->cost == cost) | |
96735eea | 521 | ospf_route_copy_nexthops (or, abr_or->paths); |
718e3744 | 522 | |
523 | else if (or->cost > cost) | |
524 | { | |
96735eea | 525 | ospf_route_subst_nexthops (or, abr_or->paths); |
718e3744 | 526 | or->cost = cost; |
527 | ||
528 | /* Even if the ABR runs in Shortcut mode, we can't change | |
529 | the path type and area, because the "or" is always bb-associated | |
530 | at this point and even Shortcut ABR can't change these attributes */ | |
531 | } | |
532 | } | |
533 | ||
4dadc291 | 534 | static int |
96735eea | 535 | process_transit_summary_lsa (struct ospf_area *area, struct route_table *rt, |
536 | struct route_table *rtrs, struct ospf_lsa *lsa) | |
718e3744 | 537 | { |
96735eea | 538 | struct ospf *ospf = area->ospf; |
718e3744 | 539 | struct summary_lsa *sl; |
540 | struct prefix_ipv4 p; | |
541 | u_int32_t metric; | |
718e3744 | 542 | |
96735eea | 543 | if (lsa == NULL) |
718e3744 | 544 | return 0; |
545 | ||
96735eea | 546 | sl = (struct summary_lsa *) lsa->data; |
718e3744 | 547 | |
548 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 549 | zlog_debug ("process_transit_summaries(): LS ID: %s", |
96735eea | 550 | inet_ntoa (lsa->data->id)); |
718e3744 | 551 | metric = GET_METRIC (sl->metric); |
552 | ||
553 | if (metric == OSPF_LS_INFINITY) | |
554 | { | |
555 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 556 | zlog_debug ("process_transit_summaries(): metric is infinity, skip"); |
718e3744 | 557 | return 0; |
558 | } | |
559 | ||
96735eea | 560 | if (IS_LSA_MAXAGE (lsa)) |
718e3744 | 561 | { |
562 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 563 | zlog_debug ("process_transit_summaries(): This LSA is too old"); |
718e3744 | 564 | return 0; |
565 | } | |
566 | ||
96735eea | 567 | if (ospf_lsa_is_self_originated (area->ospf, lsa)) |
718e3744 | 568 | { |
569 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 570 | zlog_debug ("process_transit_summaries(): This LSA is mine, skip"); |
718e3744 | 571 | return 0; |
572 | } | |
573 | ||
574 | p.family = AF_INET; | |
575 | p.prefix = sl->header.id; | |
576 | ||
577 | if (sl->header.type == OSPF_SUMMARY_LSA) | |
578 | p.prefixlen = ip_masklen (sl->mask); | |
579 | else | |
580 | p.prefixlen = IPV4_MAX_BITLEN; | |
581 | ||
582 | apply_mask_ipv4 (&p); | |
583 | ||
584 | if (sl->header.type == OSPF_SUMMARY_LSA) | |
96735eea | 585 | ospf_update_network_route (ospf, rt, rtrs, sl, &p, area); |
718e3744 | 586 | else |
96735eea | 587 | ospf_update_router_route (ospf, rtrs, sl, &p, area); |
718e3744 | 588 | |
589 | return 0; | |
590 | } | |
591 | ||
4dadc291 | 592 | static void |
718e3744 | 593 | ospf_examine_transit_summaries (struct ospf_area *area, |
718e3744 | 594 | struct route_table *lsdb_rt, |
595 | struct route_table *rt, | |
596 | struct route_table *rtrs) | |
597 | { | |
96735eea | 598 | struct ospf_lsa *lsa; |
599 | struct route_node *rn; | |
718e3744 | 600 | |
96735eea | 601 | LSDB_LOOP (lsdb_rt, rn, lsa) |
602 | process_transit_summary_lsa (area, rt, rtrs, lsa); | |
718e3744 | 603 | } |
604 | ||
605 | void | |
96735eea | 606 | ospf_ia_routing (struct ospf *ospf, |
607 | struct route_table *rt, | |
718e3744 | 608 | struct route_table *rtrs) |
609 | { | |
610 | struct ospf_area * area; | |
611 | ||
612 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 613 | zlog_debug ("ospf_ia_routing():start"); |
718e3744 | 614 | |
96735eea | 615 | if (IS_OSPF_ABR (ospf)) |
718e3744 | 616 | { |
52dc7ee6 | 617 | struct listnode *node; |
718e3744 | 618 | struct ospf_area *area; |
619 | ||
96735eea | 620 | switch (ospf->abr_type) |
718e3744 | 621 | { |
622 | case OSPF_ABR_STAND: | |
623 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 624 | zlog_debug ("ospf_ia_routing():Standard ABR"); |
718e3744 | 625 | |
96735eea | 626 | if ((area = ospf->backbone)) |
718e3744 | 627 | { |
52dc7ee6 | 628 | struct listnode *node; |
718e3744 | 629 | |
630 | if (IS_DEBUG_OSPF_EVENT) | |
631 | { | |
60925303 | 632 | zlog_debug ("ospf_ia_routing():backbone area found"); |
633 | zlog_debug ("ospf_ia_routing():examining summaries"); | |
718e3744 | 634 | } |
635 | ||
636 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); | |
637 | ||
1eb8ef25 | 638 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
639 | if (area != ospf->backbone) | |
640 | if (ospf_area_is_transit (area)) | |
641 | OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); | |
718e3744 | 642 | } |
643 | else | |
644 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 645 | zlog_debug ("ospf_ia_routing():backbone area NOT found"); |
718e3744 | 646 | break; |
647 | case OSPF_ABR_IBM: | |
648 | case OSPF_ABR_CISCO: | |
649 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 650 | zlog_debug ("ospf_ia_routing():Alternative Cisco/IBM ABR"); |
96735eea | 651 | area = ospf->backbone; /* Find the BB */ |
718e3744 | 652 | |
653 | /* If we have an active BB connection */ | |
96735eea | 654 | if (area && ospf_act_bb_connection (ospf)) |
718e3744 | 655 | { |
656 | if (IS_DEBUG_OSPF_EVENT) | |
657 | { | |
60925303 | 658 | zlog_debug ("ospf_ia_routing(): backbone area found"); |
659 | zlog_debug ("ospf_ia_routing(): examining BB summaries"); | |
718e3744 | 660 | } |
661 | ||
662 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); | |
663 | ||
1eb8ef25 | 664 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
665 | if (area != ospf->backbone) | |
666 | if (ospf_area_is_transit (area)) | |
667 | OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); | |
718e3744 | 668 | } |
669 | else | |
670 | { /* No active BB connection--consider all areas */ | |
671 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 672 | zlog_debug ("ospf_ia_routing(): " |
718e3744 | 673 | "Active BB connection not found"); |
1eb8ef25 | 674 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
675 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); | |
718e3744 | 676 | } |
677 | break; | |
678 | case OSPF_ABR_SHORTCUT: | |
679 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 680 | zlog_debug ("ospf_ia_routing():Alternative Shortcut"); |
96735eea | 681 | area = ospf->backbone; /* Find the BB */ |
718e3744 | 682 | |
683 | /* If we have an active BB connection */ | |
96735eea | 684 | if (area && ospf_act_bb_connection (ospf)) |
718e3744 | 685 | { |
686 | if (IS_DEBUG_OSPF_EVENT) | |
687 | { | |
60925303 | 688 | zlog_debug ("ospf_ia_routing(): backbone area found"); |
689 | zlog_debug ("ospf_ia_routing(): examining BB summaries"); | |
718e3744 | 690 | } |
691 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); | |
692 | } | |
693 | ||
1eb8ef25 | 694 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
695 | if (area != ospf->backbone) | |
696 | if (ospf_area_is_transit (area) || | |
697 | ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) && | |
698 | ((ospf->backbone == NULL) || | |
699 | ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) && | |
700 | area->shortcut_capability)))) | |
701 | OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); | |
718e3744 | 702 | break; |
703 | default: | |
704 | break; | |
705 | } | |
706 | } | |
707 | else | |
708 | { | |
52dc7ee6 | 709 | struct listnode *node; |
718e3744 | 710 | |
711 | if (IS_DEBUG_OSPF_EVENT) | |
60925303 | 712 | zlog_debug ("ospf_ia_routing():not ABR, considering all areas"); |
718e3744 | 713 | |
1eb8ef25 | 714 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
715 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); | |
718e3744 | 716 | } |
717 | } |