paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
| 49 | #define DEBUG |
| 50 | |
| 51 | struct ospf_route * |
| 52 | ospf_find_abr_route (struct route_table *rtrs, |
| 53 | struct prefix_ipv4 *abr, |
| 54 | struct ospf_area *area) |
| 55 | { |
| 56 | struct route_node *rn; |
| 57 | struct ospf_route *or; |
| 58 | listnode node; |
| 59 | |
| 60 | if ((rn = route_node_lookup (rtrs, (struct prefix *) abr)) == NULL) |
| 61 | return NULL; |
| 62 | |
| 63 | route_unlock_node (rn); |
| 64 | |
| 65 | for (node = listhead ((list) rn->info); node; nextnode (node)) |
| 66 | if ((or = getdata (node)) != NULL) |
| 67 | if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id) && (or->u.std.flags & ROUTER_LSA_BORDER)) |
| 68 | return or; |
| 69 | |
| 70 | return NULL; |
| 71 | } |
| 72 | |
| 73 | void |
| 74 | ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p, |
| 75 | struct ospf_route *new_or, struct ospf_route *abr_or) |
| 76 | { |
| 77 | struct route_node *rn1; |
| 78 | struct ospf_route *or; |
| 79 | |
| 80 | if (IS_DEBUG_OSPF_EVENT) |
| 81 | zlog_info ("ospf_ia_network_route(): processing summary route to %s/%d", |
| 82 | inet_ntoa (p->prefix), p->prefixlen); |
| 83 | |
| 84 | /* Find a route to the same dest */ |
| 85 | if ((rn1 = route_node_lookup (rt, (struct prefix *) p))) |
| 86 | { |
| 87 | int res; |
| 88 | |
| 89 | route_unlock_node (rn1); |
| 90 | |
| 91 | if ((or = rn1->info)) |
| 92 | { |
| 93 | if (IS_DEBUG_OSPF_EVENT) |
| 94 | zlog_info ("ospf_ia_network_route(): " |
| 95 | "Found a route to the same network"); |
| 96 | /* Check the existing route. */ |
| 97 | if ((res = ospf_route_cmp (new_or, or)) < 0) |
| 98 | { |
| 99 | /* New route is better, so replace old one. */ |
| 100 | ospf_route_subst (rn1, new_or, abr_or); |
| 101 | } |
| 102 | else if (res == 0) |
| 103 | { |
| 104 | /* New and old route are equal, so next hops can be added. */ |
| 105 | route_lock_node (rn1); |
| 106 | ospf_route_copy_nexthops (or, abr_or->path); |
| 107 | route_unlock_node (rn1); |
| 108 | |
| 109 | /* new route can be deleted, because existing route has been updated. */ |
| 110 | ospf_route_free (new_or); |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | /* New route is worse, so free it. */ |
| 115 | ospf_route_free (new_or); |
| 116 | return; |
| 117 | } |
| 118 | } /* if (or)*/ |
| 119 | } /*if (rn1)*/ |
| 120 | else |
| 121 | { /* no route */ |
| 122 | if (IS_DEBUG_OSPF_EVENT) |
| 123 | zlog_info ("ospf_ia_network_route(): add new route to %s/%d", |
| 124 | inet_ntoa (p->prefix), p->prefixlen); |
| 125 | ospf_route_add (rt, p, new_or, abr_or); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | void |
| 130 | ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p, |
| 131 | struct ospf_route *new_or, struct ospf_route *abr_or) |
| 132 | { |
| 133 | struct route_node *rn; |
| 134 | struct ospf_route *or = NULL; |
| 135 | int ret; |
| 136 | |
| 137 | if (IS_DEBUG_OSPF_EVENT) |
| 138 | zlog_info ("ospf_ia_router_route(): considering %s/%d", |
| 139 | inet_ntoa (p->prefix), p->prefixlen); |
| 140 | /* Find a route to the same dest */ |
| 141 | rn = route_node_get (rt,(struct prefix *) p); |
| 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; |
| 149 | or_area = ospf_area_lookup_by_area_id (new_or->u.std.area_id); |
| 150 | assert (or_area); |
| 151 | /* This is an additional route */ |
| 152 | route_unlock_node (rn); |
| 153 | or = ospf_find_asbr_route_through_area (rt, p, or_area); |
| 154 | } |
| 155 | |
| 156 | if (or) |
| 157 | { |
| 158 | if (IS_DEBUG_OSPF_EVENT) |
| 159 | zlog_info ("ospf_ia_router_route(): " |
| 160 | "a route to the same ABR through the same area exists"); |
| 161 | /* New route is better */ |
| 162 | if ((ret = ospf_route_cmp (new_or, or)) < 0) |
| 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) |
| 172 | zlog_info ("ospf_ia_router_route(): merging the new route"); |
| 173 | |
| 174 | ospf_route_copy_nexthops (or, abr_or->path); |
| 175 | ospf_route_free (new_or); |
| 176 | return; |
| 177 | } |
| 178 | /* New route is worse */ |
| 179 | else |
| 180 | { |
| 181 | if (IS_DEBUG_OSPF_EVENT) |
| 182 | zlog_info ("ospf_ia_router_route(): skipping the new route"); |
| 183 | ospf_route_free (new_or); |
| 184 | return; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | ospf_route_copy_nexthops (new_or, abr_or->path); |
| 189 | |
| 190 | if (IS_DEBUG_OSPF_EVENT) |
| 191 | zlog_info ("ospf_ia_router_route(): adding the new route"); |
| 192 | |
| 193 | listnode_add (rn->info, new_or); |
| 194 | } |
| 195 | |
| 196 | |
| 197 | struct ia_args |
| 198 | { |
| 199 | struct route_table *rt; |
| 200 | struct route_table *rtrs; |
| 201 | struct ospf_area *area; |
| 202 | }; |
| 203 | |
| 204 | int |
| 205 | process_summary_lsa (struct ospf_lsa *l, void *v, int i) |
| 206 | { |
| 207 | struct ospf_area_range *range; |
| 208 | struct ospf_route *abr_or, *new_or; |
| 209 | struct summary_lsa *sl; |
| 210 | struct prefix_ipv4 p, abr; |
| 211 | u_int32_t metric; |
| 212 | struct ia_args *args; |
| 213 | |
| 214 | if (l == NULL) |
| 215 | return 0; |
| 216 | |
| 217 | args = (struct ia_args *) v; |
| 218 | sl = (struct summary_lsa *) l->data; |
| 219 | |
| 220 | if (IS_DEBUG_OSPF_EVENT) |
| 221 | zlog_info ("process_summary_lsa(): LS ID: %s", inet_ntoa (sl->header.id)); |
| 222 | |
| 223 | metric = GET_METRIC (sl->metric); |
| 224 | |
| 225 | if (metric == OSPF_LS_INFINITY) |
| 226 | return 0; |
| 227 | |
| 228 | if (IS_LSA_MAXAGE (l)) |
| 229 | return 0; |
| 230 | |
| 231 | if (ospf_lsa_is_self_originated (l)) |
| 232 | return 0; |
| 233 | |
| 234 | p.family = AF_INET; |
| 235 | p.prefix = sl->header.id; |
| 236 | |
| 237 | if (sl->header.type == OSPF_SUMMARY_LSA) |
| 238 | p.prefixlen = ip_masklen (sl->mask); |
| 239 | else |
| 240 | p.prefixlen = IPV4_MAX_BITLEN; |
| 241 | |
| 242 | apply_mask_ipv4 (&p); |
| 243 | |
| 244 | if (sl->header.type == OSPF_SUMMARY_LSA && |
| 245 | (range = ospf_area_range_match_any (ospf_top, &p)) && |
| 246 | ospf_area_range_active (range)) |
| 247 | return 0; |
| 248 | |
| 249 | if (ospf_top->abr_type != OSPF_ABR_STAND && |
| 250 | args->area->external_routing != OSPF_AREA_DEFAULT && |
| 251 | p.prefix.s_addr == OSPF_DEFAULT_DESTINATION && |
| 252 | p.prefixlen == 0) |
| 253 | return 0; /* Ignore summary default from a stub area */ |
| 254 | |
| 255 | abr.family = AF_INET; |
| 256 | abr.prefix = sl->header.adv_router; |
| 257 | abr.prefixlen = IPV4_MAX_BITLEN; |
| 258 | apply_mask_ipv4 (&abr); |
| 259 | |
| 260 | abr_or = ospf_find_abr_route (args->rtrs, &abr, args->area); |
| 261 | |
| 262 | if (abr_or == NULL) |
| 263 | return 0; |
| 264 | |
| 265 | new_or = ospf_route_new (); |
| 266 | new_or->type = OSPF_DESTINATION_NETWORK; |
| 267 | new_or->id = sl->header.id; |
| 268 | new_or->mask = sl->mask; |
| 269 | new_or->u.std.options = sl->header.options; |
| 270 | new_or->u.std.origin = (struct lsa_header *) sl; |
| 271 | new_or->cost = abr_or->cost + metric; |
| 272 | new_or->u.std.area_id = args->area->area_id; |
| 273 | #ifdef HAVE_NSSA |
| 274 | new_or->u.std.external_routing = args->area->external_routing; |
| 275 | #endif /* HAVE_NSSA */ |
| 276 | new_or->path_type = OSPF_PATH_INTER_AREA; |
| 277 | |
| 278 | if (sl->header.type == OSPF_SUMMARY_LSA) |
| 279 | ospf_ia_network_route (args->rt, &p, new_or, abr_or); |
| 280 | else |
| 281 | { |
| 282 | new_or->type = OSPF_DESTINATION_ROUTER; |
| 283 | new_or->u.std.flags = ROUTER_LSA_EXTERNAL; |
| 284 | ospf_ia_router_route (args->rtrs, &p, new_or, abr_or); |
| 285 | } |
| 286 | |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | void |
| 291 | ospf_examine_summaries (struct ospf_area * area, |
| 292 | struct route_table *lsdb_rt, |
| 293 | struct route_table *rt, |
| 294 | struct route_table *rtrs) |
| 295 | { |
| 296 | struct ia_args args = {rt, rtrs, area}; |
| 297 | foreach_lsa (lsdb_rt, &args, 0, process_summary_lsa); |
| 298 | } |
| 299 | |
| 300 | int |
| 301 | ospf_area_is_transit (struct ospf_area *area) |
| 302 | { |
| 303 | return (area->transit == OSPF_TRANSIT_TRUE) || |
| 304 | ospf_full_virtual_nbrs(area); /* Cisco forgets to set the V-bit :( */ |
| 305 | } |
| 306 | |
| 307 | void |
| 308 | ospf_update_network_route (struct route_table *rt, |
| 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) |
| 329 | zlog_info ("ospf_update_network_route(): can't find a route to the ABR"); |
| 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 | { |
| 339 | if (ospf_top->abr_type != OSPF_ABR_SHORTCUT) |
| 340 | return; /* Standard ABR can update only already installed |
| 341 | backbone paths */ |
| 342 | if (IS_DEBUG_OSPF_EVENT) |
| 343 | zlog_info ("ospf_update_network_route(): " |
| 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; |
| 353 | #ifdef HAVE_NSSA |
| 354 | new_or->u.std.external_routing = area->external_routing; |
| 355 | #endif /* HAVE_NSSA */ |
| 356 | new_or->path_type = OSPF_PATH_INTER_AREA; |
| 357 | ospf_route_add (rt, p, new_or, abr_or); |
| 358 | |
| 359 | return; |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | route_unlock_node (rn); |
| 364 | if (rn->info == NULL) |
| 365 | return; |
| 366 | } |
| 367 | |
| 368 | or = rn->info; |
| 369 | |
| 370 | if (or->path_type != OSPF_PATH_INTRA_AREA && |
| 371 | or->path_type != OSPF_PATH_INTER_AREA) |
| 372 | { |
| 373 | if (IS_DEBUG_OSPF_EVENT) |
| 374 | zlog_info ("ospf_update_network_route(): ERR: path type is wrong"); |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | if (ospf_top->abr_type == OSPF_ABR_SHORTCUT) |
| 379 | { |
| 380 | if (or->path_type == OSPF_PATH_INTRA_AREA && |
| 381 | !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) |
| 382 | { |
| 383 | if (IS_DEBUG_OSPF_EVENT) |
| 384 | zlog_info ("ospf_update_network_route(): Shortcut: " |
| 385 | "this intra-area path is not backbone"); |
| 386 | return; |
| 387 | } |
| 388 | } |
| 389 | else /* Not Shortcut ABR */ |
| 390 | { |
| 391 | if (!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) |
| 392 | { |
| 393 | if (IS_DEBUG_OSPF_EVENT) |
| 394 | zlog_info ("ospf_update_network_route(): " |
| 395 | "route is not BB-associated"); |
| 396 | return; /* We can update only BB routes */ |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | if (or->cost < cost) |
| 401 | { |
| 402 | if (IS_DEBUG_OSPF_EVENT) |
| 403 | zlog_info ("ospf_update_network_route(): new route is worse"); |
| 404 | return; |
| 405 | } |
| 406 | |
| 407 | if (or->cost == cost) |
| 408 | { |
| 409 | if (IS_DEBUG_OSPF_EVENT) |
| 410 | zlog_info ("ospf_update_network_route(): " |
| 411 | "new route is same distance, adding nexthops"); |
| 412 | ospf_route_copy_nexthops (or, abr_or->path); |
| 413 | } |
| 414 | |
| 415 | if (or->cost > cost) |
| 416 | { |
| 417 | if (IS_DEBUG_OSPF_EVENT) |
| 418 | zlog_info ("ospf_update_network_route(): " |
| 419 | "new route is better, overriding nexthops"); |
| 420 | ospf_route_subst_nexthops (or, abr_or->path); |
| 421 | or->cost = cost; |
| 422 | |
| 423 | if ((ospf_top->abr_type == OSPF_ABR_SHORTCUT) && |
| 424 | !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) |
| 425 | { |
| 426 | or->path_type = OSPF_PATH_INTER_AREA; |
| 427 | or->u.std.area_id = area->area_id; |
| 428 | #ifdef HAVE_NSSA |
| 429 | or->u.std.external_routing = area->external_routing; |
| 430 | #endif /* HAVE_NSSA */ |
| 431 | /* Note that we can do this only in Shortcut ABR mode, |
| 432 | because standard ABR must leave the route type and area |
| 433 | unchanged |
| 434 | */ |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | void |
| 440 | ospf_update_router_route (struct route_table *rtrs, |
| 441 | struct summary_lsa *lsa, |
| 442 | struct prefix_ipv4 *p, |
| 443 | struct ospf_area *area) |
| 444 | { |
| 445 | struct ospf_route *or, *abr_or, *new_or; |
| 446 | struct prefix_ipv4 abr; |
| 447 | u_int32_t cost; |
| 448 | |
| 449 | abr.family = AF_INET; |
| 450 | abr.prefix = lsa->header.adv_router; |
| 451 | abr.prefixlen = IPV4_MAX_BITLEN; |
| 452 | apply_mask_ipv4 (&abr); |
| 453 | |
| 454 | abr_or = ospf_find_abr_route (rtrs, &abr, area); |
| 455 | |
| 456 | if (abr_or == NULL) |
| 457 | { |
| 458 | if (IS_DEBUG_OSPF_EVENT) |
| 459 | zlog_info ("ospf_update_router_route(): can't find a route to the ABR"); |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | cost = abr_or->cost + GET_METRIC (lsa->metric); |
| 464 | |
| 465 | /* First try to find a backbone path, |
| 466 | because standard ABR can update only BB-associated paths */ |
| 467 | |
| 468 | if ((ospf_top->backbone == NULL) && |
| 469 | (ospf_top->abr_type != OSPF_ABR_SHORTCUT)) |
| 470 | |
| 471 | /* no BB area, not Shortcut ABR, exiting */ |
| 472 | return; |
| 473 | |
| 474 | or = ospf_find_asbr_route_through_area (rtrs, p, ospf_top->backbone); |
| 475 | |
| 476 | if (or == NULL) |
| 477 | { |
| 478 | if (ospf_top->abr_type != OSPF_ABR_SHORTCUT) |
| 479 | |
| 480 | /* route to ASBR through the BB not found |
| 481 | the router is not Shortcut ABR, exiting */ |
| 482 | |
| 483 | return; |
| 484 | else |
| 485 | /* We're a Shortcut ABR*/ |
| 486 | { |
| 487 | /* Let it either add a new router or update the route |
| 488 | through the same (non-BB) area. */ |
| 489 | |
| 490 | new_or = ospf_route_new (); |
| 491 | new_or->type = OSPF_DESTINATION_ROUTER; |
| 492 | new_or->id = lsa->header.id; |
| 493 | new_or->mask = lsa->mask; |
| 494 | new_or->u.std.options = lsa->header.options; |
| 495 | new_or->u.std.origin = (struct lsa_header *)lsa; |
| 496 | new_or->cost = cost; |
| 497 | new_or->u.std.area_id = area->area_id; |
| 498 | #ifdef HAVE_NSSA |
| 499 | new_or->u.std.external_routing = area->external_routing; |
| 500 | #endif /* HAVE_NSSA */ |
| 501 | new_or->path_type = OSPF_PATH_INTER_AREA; |
| 502 | new_or->u.std.flags = ROUTER_LSA_EXTERNAL; |
| 503 | ospf_ia_router_route (rtrs, p, new_or, abr_or); |
| 504 | |
| 505 | return; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | /* At this point the "or" is always bb-associated */ |
| 510 | |
| 511 | if (!(or->u.std.flags & ROUTER_LSA_EXTERNAL)) |
| 512 | { |
| 513 | if (IS_DEBUG_OSPF_EVENT) |
| 514 | zlog_info ("ospf_upd_router_route(): the remote router is not an ASBR"); |
| 515 | return; |
| 516 | } |
| 517 | |
| 518 | if (or->path_type != OSPF_PATH_INTRA_AREA && |
| 519 | or->path_type != OSPF_PATH_INTER_AREA) |
| 520 | return; |
| 521 | |
| 522 | if (or->cost < cost) |
| 523 | return; |
| 524 | |
| 525 | else if (or->cost == cost) |
| 526 | ospf_route_copy_nexthops (or, abr_or->path); |
| 527 | |
| 528 | else if (or->cost > cost) |
| 529 | { |
| 530 | ospf_route_subst_nexthops (or, abr_or->path); |
| 531 | or->cost = cost; |
| 532 | |
| 533 | /* Even if the ABR runs in Shortcut mode, we can't change |
| 534 | the path type and area, because the "or" is always bb-associated |
| 535 | at this point and even Shortcut ABR can't change these attributes */ |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | int |
| 540 | process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i) |
| 541 | { |
| 542 | struct summary_lsa *sl; |
| 543 | struct prefix_ipv4 p; |
| 544 | u_int32_t metric; |
| 545 | struct ia_args *args; |
| 546 | |
| 547 | if (l == NULL) |
| 548 | return 0; |
| 549 | |
| 550 | args = (struct ia_args *) v; |
| 551 | sl = (struct summary_lsa *) l->data; |
| 552 | |
| 553 | if (IS_DEBUG_OSPF_EVENT) |
| 554 | zlog_info ("process_transit_summaries(): LS ID: %s", |
| 555 | inet_ntoa (l->data->id)); |
| 556 | metric = GET_METRIC (sl->metric); |
| 557 | |
| 558 | if (metric == OSPF_LS_INFINITY) |
| 559 | { |
| 560 | if (IS_DEBUG_OSPF_EVENT) |
| 561 | zlog_info ("process_transit_summaries(): metric is infinity, skip"); |
| 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | if (IS_LSA_MAXAGE (l)) |
| 566 | { |
| 567 | if (IS_DEBUG_OSPF_EVENT) |
| 568 | zlog_info ("process_transit_summaries(): This LSA is too old"); |
| 569 | return 0; |
| 570 | } |
| 571 | |
| 572 | if (ospf_lsa_is_self_originated (l)) |
| 573 | { |
| 574 | if (IS_DEBUG_OSPF_EVENT) |
| 575 | zlog_info ("process_transit_summaries(): This LSA is mine, skip"); |
| 576 | return 0; |
| 577 | } |
| 578 | |
| 579 | p.family = AF_INET; |
| 580 | p.prefix = sl->header.id; |
| 581 | |
| 582 | if (sl->header.type == OSPF_SUMMARY_LSA) |
| 583 | p.prefixlen = ip_masklen (sl->mask); |
| 584 | else |
| 585 | p.prefixlen = IPV4_MAX_BITLEN; |
| 586 | |
| 587 | apply_mask_ipv4 (&p); |
| 588 | |
| 589 | if (sl->header.type == OSPF_SUMMARY_LSA) |
| 590 | ospf_update_network_route (args->rt, args->rtrs, sl, &p, args->area); |
| 591 | else |
| 592 | ospf_update_router_route (args->rtrs, sl, &p, args->area); |
| 593 | |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | void |
| 598 | ospf_examine_transit_summaries (struct ospf_area *area, |
| 599 | /* struct ospf_lsdb *lsdb, */ |
| 600 | struct route_table *lsdb_rt, |
| 601 | struct route_table *rt, |
| 602 | struct route_table *rtrs) |
| 603 | { |
| 604 | struct ia_args args = {rt, rtrs, area}; |
| 605 | |
| 606 | /* ospf_lsdb_iterator (lsdb, &args, 0, process_transit_summary_lsa); */ |
| 607 | foreach_lsa (lsdb_rt, &args, 0, process_transit_summary_lsa); |
| 608 | } |
| 609 | |
| 610 | void |
| 611 | ospf_ia_routing (struct route_table *rt, |
| 612 | struct route_table *rtrs) |
| 613 | { |
| 614 | struct ospf_area * area; |
| 615 | |
| 616 | if (IS_DEBUG_OSPF_EVENT) |
| 617 | zlog_info ("ospf_ia_routing():start"); |
| 618 | |
| 619 | if (OSPF_IS_ABR) |
| 620 | { |
| 621 | listnode node; |
| 622 | struct ospf_area *area; |
| 623 | |
| 624 | switch (ospf_top->abr_type) |
| 625 | { |
| 626 | case OSPF_ABR_STAND: |
| 627 | if (IS_DEBUG_OSPF_EVENT) |
| 628 | zlog_info ("ospf_ia_routing():Standard ABR"); |
| 629 | |
| 630 | if ((area = ospf_top->backbone)) |
| 631 | { |
| 632 | listnode node; |
| 633 | |
| 634 | if (IS_DEBUG_OSPF_EVENT) |
| 635 | { |
| 636 | zlog_info ("ospf_ia_routing():backbone area found"); |
| 637 | zlog_info ("ospf_ia_routing():examining summaries"); |
| 638 | } |
| 639 | |
| 640 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); |
| 641 | |
| 642 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 643 | if ((area = getdata (node)) != NULL) |
| 644 | if (area != ospf_top->backbone) |
| 645 | if (ospf_area_is_transit (area)) |
| 646 | OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); |
| 647 | } |
| 648 | else |
| 649 | if (IS_DEBUG_OSPF_EVENT) |
| 650 | zlog_info ("ospf_ia_routing():backbone area NOT found"); |
| 651 | break; |
| 652 | case OSPF_ABR_IBM: |
| 653 | case OSPF_ABR_CISCO: |
| 654 | if (IS_DEBUG_OSPF_EVENT) |
| 655 | zlog_info ("ospf_ia_routing():Alternative Cisco/IBM ABR"); |
| 656 | area = ospf_top->backbone; /* Find the BB */ |
| 657 | |
| 658 | /* If we have an active BB connection */ |
| 659 | if (area && ospf_act_bb_connection ()) |
| 660 | { |
| 661 | if (IS_DEBUG_OSPF_EVENT) |
| 662 | { |
| 663 | zlog_info ("ospf_ia_routing(): backbone area found"); |
| 664 | zlog_info ("ospf_ia_routing(): examining BB summaries"); |
| 665 | } |
| 666 | |
| 667 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); |
| 668 | |
| 669 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 670 | if ((area = getdata (node)) != NULL) |
| 671 | if (area != ospf_top->backbone) |
| 672 | if (ospf_area_is_transit (area)) |
| 673 | OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); |
| 674 | } |
| 675 | else |
| 676 | { /* No active BB connection--consider all areas */ |
| 677 | if (IS_DEBUG_OSPF_EVENT) |
| 678 | zlog_info ("ospf_ia_routing(): " |
| 679 | "Active BB connection not found"); |
| 680 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 681 | if ((area = getdata (node)) != NULL) |
| 682 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); |
| 683 | } |
| 684 | break; |
| 685 | case OSPF_ABR_SHORTCUT: |
| 686 | if (IS_DEBUG_OSPF_EVENT) |
| 687 | zlog_info ("ospf_ia_routing():Alternative Shortcut"); |
| 688 | area = ospf_top->backbone; /* Find the BB */ |
| 689 | |
| 690 | /* If we have an active BB connection */ |
| 691 | if (area && ospf_act_bb_connection ()) |
| 692 | { |
| 693 | if (IS_DEBUG_OSPF_EVENT) |
| 694 | { |
| 695 | zlog_info ("ospf_ia_routing(): backbone area found"); |
| 696 | zlog_info ("ospf_ia_routing(): examining BB summaries"); |
| 697 | } |
| 698 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); |
| 699 | } |
| 700 | |
| 701 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 702 | if ((area = getdata (node)) != NULL) |
| 703 | if (area != ospf_top->backbone) |
| 704 | if (ospf_area_is_transit (area) || |
| 705 | ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) && |
| 706 | ((ospf_top->backbone == NULL) || |
| 707 | ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) && |
| 708 | area->shortcut_capability)))) |
| 709 | OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); |
| 710 | break; |
| 711 | default: |
| 712 | break; |
| 713 | } |
| 714 | } |
| 715 | else |
| 716 | { |
| 717 | listnode node; |
| 718 | |
| 719 | if (IS_DEBUG_OSPF_EVENT) |
| 720 | zlog_info ("ospf_ia_routing():not ABR, considering all areas"); |
| 721 | |
| 722 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 723 | if ((area = getdata (node)) != NULL) |
| 724 | OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); |
| 725 | } |
| 726 | } |