paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * OSPF ABR functions. |
| 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 "linklist.h" |
| 29 | #include "prefix.h" |
| 30 | #include "if.h" |
| 31 | #include "table.h" |
| 32 | #include "vty.h" |
| 33 | #include "filter.h" |
| 34 | #include "plist.h" |
| 35 | #include "log.h" |
| 36 | |
| 37 | #include "ospfd/ospfd.h" |
| 38 | #include "ospfd/ospf_interface.h" |
| 39 | #include "ospfd/ospf_ism.h" |
| 40 | #include "ospfd/ospf_asbr.h" |
| 41 | #include "ospfd/ospf_lsa.h" |
| 42 | #include "ospfd/ospf_lsdb.h" |
| 43 | #include "ospfd/ospf_neighbor.h" |
| 44 | #include "ospfd/ospf_nsm.h" |
| 45 | #include "ospfd/ospf_spf.h" |
| 46 | #include "ospfd/ospf_route.h" |
| 47 | #include "ospfd/ospf_ia.h" |
| 48 | #include "ospfd/ospf_flood.h" |
| 49 | #include "ospfd/ospf_abr.h" |
| 50 | #include "ospfd/ospf_ase.h" |
| 51 | #include "ospfd/ospf_zebra.h" |
| 52 | #include "ospfd/ospf_dump.h" |
| 53 | |
| 54 | |
| 55 | struct ospf_area_range * |
| 56 | ospf_area_range_new (struct prefix_ipv4 *p) |
| 57 | { |
| 58 | struct ospf_area_range *range; |
| 59 | |
| 60 | range = XCALLOC (MTYPE_OSPF_AREA_RANGE, sizeof (struct ospf_area_range)); |
| 61 | range->addr = p->prefix; |
| 62 | range->masklen = p->prefixlen; |
| 63 | range->cost_config = OSPF_AREA_RANGE_COST_UNSPEC; |
| 64 | |
| 65 | return range; |
| 66 | } |
| 67 | |
| 68 | void |
| 69 | ospf_area_range_free (struct ospf_area_range *range) |
| 70 | { |
| 71 | XFREE (MTYPE_OSPF_AREA_RANGE, range); |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | ospf_area_range_add (struct ospf_area *area, struct ospf_area_range *range) |
| 76 | { |
| 77 | struct route_node *rn; |
| 78 | struct prefix_ipv4 p; |
| 79 | |
| 80 | p.family = AF_INET; |
| 81 | p.prefixlen = range->masklen; |
| 82 | p.prefix = range->addr; |
| 83 | |
| 84 | rn = route_node_get (area->ranges, (struct prefix *)&p); |
| 85 | if (rn->info) |
| 86 | route_unlock_node (rn); |
| 87 | else |
| 88 | rn->info = range; |
| 89 | } |
| 90 | |
| 91 | void |
| 92 | ospf_area_range_delete (struct ospf_area *area, struct ospf_area_range *range) |
| 93 | { |
| 94 | struct route_node *rn; |
| 95 | struct prefix_ipv4 p; |
| 96 | |
| 97 | p.family = AF_INET; |
| 98 | p.prefixlen = range->masklen; |
| 99 | p.prefix = range->addr; |
| 100 | |
| 101 | rn = route_node_lookup (area->ranges, (struct prefix *)&p); |
| 102 | if (rn) |
| 103 | { |
| 104 | ospf_area_range_free (rn->info); |
| 105 | rn->info = NULL; |
| 106 | route_unlock_node (rn); |
| 107 | route_unlock_node (rn); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | struct ospf_area_range * |
| 112 | ospf_area_range_lookup (struct ospf_area *area, struct prefix_ipv4 *p) |
| 113 | { |
| 114 | struct route_node *rn; |
| 115 | |
| 116 | rn = route_node_lookup (area->ranges, (struct prefix *)p); |
| 117 | if (rn) |
| 118 | { |
| 119 | route_unlock_node (rn); |
| 120 | return rn->info; |
| 121 | } |
| 122 | return NULL; |
| 123 | } |
| 124 | |
| 125 | struct ospf_area_range * |
| 126 | ospf_area_range_lookup_next (struct ospf_area *area, struct in_addr *range_net, |
| 127 | int first) |
| 128 | { |
| 129 | struct route_node *rn; |
| 130 | struct prefix_ipv4 p; |
| 131 | struct ospf_area_range *find; |
| 132 | |
| 133 | p.family = AF_INET; |
| 134 | p.prefixlen = IPV4_MAX_BITLEN; |
| 135 | p.prefix = *range_net; |
| 136 | |
| 137 | if (first) |
| 138 | rn = route_top (area->ranges); |
| 139 | else |
| 140 | { |
| 141 | rn = route_node_get (area->ranges, (struct prefix *) &p); |
| 142 | rn = route_next (rn); |
| 143 | } |
| 144 | |
| 145 | for (; rn; rn = route_next (rn)) |
| 146 | if (rn->info) |
| 147 | break; |
| 148 | |
| 149 | if (rn && rn->info) |
| 150 | { |
| 151 | find = rn->info; |
| 152 | *range_net = rn->p.u.prefix4; |
| 153 | route_unlock_node (rn); |
| 154 | return find; |
| 155 | } |
| 156 | return NULL; |
| 157 | } |
| 158 | |
| 159 | struct ospf_area_range * |
| 160 | ospf_area_range_match (struct ospf_area *area, struct prefix_ipv4 *p) |
| 161 | { |
| 162 | struct route_node *node; |
| 163 | |
| 164 | node = route_node_match (area->ranges, (struct prefix *) p); |
| 165 | if (node) |
| 166 | { |
| 167 | route_unlock_node (node); |
| 168 | return node->info; |
| 169 | } |
| 170 | return NULL; |
| 171 | } |
| 172 | |
| 173 | struct ospf_area_range * |
| 174 | ospf_area_range_match_any (struct ospf *ospf, struct prefix_ipv4 *p) |
| 175 | { |
| 176 | struct ospf_area_range *range; |
| 177 | listnode node; |
| 178 | |
| 179 | for (node = listhead (ospf->areas); node; nextnode (node)) |
| 180 | if ((range = ospf_area_range_match (node->data, p))) |
| 181 | return range; |
| 182 | |
| 183 | return NULL; |
| 184 | } |
| 185 | |
| 186 | int |
| 187 | ospf_area_range_active (struct ospf_area_range *range) |
| 188 | { |
| 189 | return range->specifics; |
| 190 | } |
| 191 | |
| 192 | int |
| 193 | ospf_area_actively_attached (struct ospf_area *area) |
| 194 | { |
| 195 | return area->act_ints; |
| 196 | } |
| 197 | |
| 198 | int |
| 199 | ospf_area_range_set (struct ospf *ospf, struct in_addr area_id, |
| 200 | struct prefix_ipv4 *p, int advertise) |
| 201 | { |
| 202 | struct ospf_area *area; |
| 203 | struct ospf_area_range *range; |
| 204 | int ret = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 205 | |
| 206 | area = ospf_area_get (area_id, ret); |
| 207 | if (area == NULL) |
| 208 | return 0; |
| 209 | |
| 210 | range = ospf_area_range_lookup (area, p); |
| 211 | if (range != NULL) |
| 212 | { |
| 213 | if ((CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE) |
| 214 | && !CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE)) |
| 215 | || (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE) |
| 216 | && CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))) |
| 217 | ospf_schedule_abr_task (); |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | range = ospf_area_range_new (p); |
| 222 | ospf_area_range_add (area, range); |
| 223 | ospf_schedule_abr_task (); |
| 224 | } |
| 225 | |
| 226 | if (CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE)) |
| 227 | SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE); |
| 228 | else |
| 229 | UNSET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE); |
| 230 | |
| 231 | return 1; |
| 232 | } |
| 233 | |
| 234 | int |
| 235 | ospf_area_range_cost_set (struct ospf *ospf, struct in_addr area_id, |
| 236 | struct prefix_ipv4 *p, u_int32_t cost) |
| 237 | { |
| 238 | struct ospf_area *area; |
| 239 | struct ospf_area_range *range; |
| 240 | int ret = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 241 | |
| 242 | area = ospf_area_get (area_id, ret); |
| 243 | if (area == NULL) |
| 244 | return 0; |
| 245 | |
| 246 | range = ospf_area_range_new (p); |
| 247 | if (range == NULL) |
| 248 | return 0; |
| 249 | |
| 250 | if (range->cost_config != cost) |
| 251 | { |
| 252 | range->cost_config = cost; |
| 253 | if (ospf_area_range_active (range)) |
| 254 | ospf_schedule_abr_task (); |
| 255 | } |
| 256 | |
| 257 | return 1; |
| 258 | } |
| 259 | |
| 260 | int |
| 261 | ospf_area_range_unset (struct ospf *ospf, struct in_addr area_id, |
| 262 | struct prefix_ipv4 *p) |
| 263 | { |
| 264 | struct ospf_area *area; |
| 265 | struct ospf_area_range *range; |
| 266 | |
| 267 | area = ospf_area_lookup_by_area_id (area_id); |
| 268 | if (area == NULL) |
| 269 | return 0; |
| 270 | |
| 271 | range = ospf_area_range_lookup (area, p); |
| 272 | if (range == NULL) |
| 273 | return 0; |
| 274 | |
| 275 | if (ospf_area_range_active (range)) |
| 276 | ospf_schedule_abr_task (); |
| 277 | |
| 278 | ospf_area_range_delete (area, range); |
| 279 | |
| 280 | return 1; |
| 281 | } |
| 282 | |
| 283 | int |
| 284 | ospf_area_range_substitute_set (struct ospf *ospf, struct in_addr area_id, |
| 285 | struct prefix_ipv4 *p, struct prefix_ipv4 *s) |
| 286 | { |
| 287 | struct ospf_area *area; |
| 288 | struct ospf_area_range *range; |
| 289 | int ret = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 290 | |
| 291 | area = ospf_area_get (area_id, ret); |
| 292 | range = ospf_area_range_lookup (area, p); |
| 293 | |
| 294 | if (range != NULL) |
| 295 | { |
| 296 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE) || |
| 297 | !CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 298 | ospf_schedule_abr_task (); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | range = ospf_area_range_new (p); |
| 303 | ospf_area_range_add (area, range); |
| 304 | ospf_schedule_abr_task (); |
| 305 | } |
| 306 | |
| 307 | SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE); |
| 308 | SET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE); |
| 309 | range->subst_addr = s->prefix; |
| 310 | range->subst_masklen = s->prefixlen; |
| 311 | |
| 312 | return 1; |
| 313 | } |
| 314 | |
| 315 | int |
| 316 | ospf_area_range_substitute_unset (struct ospf *ospf, struct in_addr area_id, |
| 317 | struct prefix_ipv4 *p) |
| 318 | { |
| 319 | struct ospf_area *area; |
| 320 | struct ospf_area_range *range; |
| 321 | |
| 322 | area = ospf_area_lookup_by_area_id (area_id); |
| 323 | if (area == NULL) |
| 324 | return 0; |
| 325 | |
| 326 | range = ospf_area_range_lookup (area, p); |
| 327 | if (range == NULL) |
| 328 | return 0; |
| 329 | |
| 330 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 331 | if (ospf_area_range_active (range)) |
| 332 | ospf_schedule_abr_task (); |
| 333 | |
| 334 | UNSET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE); |
| 335 | range->subst_addr.s_addr = 0; |
| 336 | range->subst_masklen = 0; |
| 337 | |
| 338 | return 1; |
| 339 | } |
| 340 | |
| 341 | int |
| 342 | ospf_act_bb_connection () |
| 343 | { |
| 344 | if (ospf_top->backbone == NULL) |
| 345 | return 0; |
| 346 | |
| 347 | return ospf_top->backbone->full_nbrs; |
| 348 | } |
| 349 | |
| 350 | /* Check area border router status. */ |
| 351 | void |
| 352 | ospf_check_abr_status () |
| 353 | { |
| 354 | struct ospf_area *area; |
| 355 | listnode node; |
| 356 | int bb_configured = 0; |
| 357 | int bb_act_attached = 0; |
| 358 | int areas_configured = 0; |
| 359 | int areas_act_attached = 0; |
| 360 | |
| 361 | u_char new_flags = ospf_top->flags; |
| 362 | |
| 363 | if (IS_DEBUG_OSPF_EVENT) |
| 364 | zlog_info ("ospf_check_abr_status(): Start"); |
| 365 | |
| 366 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 367 | { |
| 368 | area = getdata (node); |
| 369 | |
| 370 | if (listcount (area->oiflist)) |
| 371 | { |
| 372 | areas_configured++; |
| 373 | |
| 374 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 375 | bb_configured = 1; |
| 376 | } |
| 377 | |
| 378 | if (ospf_area_actively_attached (area)) |
| 379 | { |
| 380 | areas_act_attached++; |
| 381 | |
| 382 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 383 | bb_act_attached = 1; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | if (IS_DEBUG_OSPF_EVENT) |
| 388 | { |
| 389 | zlog_info ("ospf_check_abr_status(): looked through areas"); |
| 390 | zlog_info ("ospf_check_abr_status(): bb_configured: %d", bb_configured); |
| 391 | zlog_info ("ospf_check_abr_status(): bb_act_attached: %d", |
| 392 | bb_act_attached); |
| 393 | zlog_info ("ospf_check_abr_status(): areas_configured: %d", |
| 394 | areas_configured); |
| 395 | zlog_info ("ospf_check_abr_status(): areas_act_attached: %d", |
| 396 | areas_act_attached); |
| 397 | } |
| 398 | |
| 399 | switch (ospf_top->abr_type) |
| 400 | { |
| 401 | case OSPF_ABR_SHORTCUT: |
| 402 | case OSPF_ABR_STAND: |
| 403 | if (areas_act_attached > 1) |
| 404 | SET_FLAG (new_flags, OSPF_FLAG_ABR); |
| 405 | else |
| 406 | UNSET_FLAG (new_flags, OSPF_FLAG_ABR); |
| 407 | break; |
| 408 | |
| 409 | case OSPF_ABR_IBM: |
| 410 | if ((areas_act_attached > 1) && bb_configured) |
| 411 | SET_FLAG (new_flags, OSPF_FLAG_ABR); |
| 412 | else |
| 413 | UNSET_FLAG (new_flags, OSPF_FLAG_ABR); |
| 414 | break; |
| 415 | |
| 416 | case OSPF_ABR_CISCO: |
| 417 | if ((areas_configured > 1) && bb_act_attached) |
| 418 | SET_FLAG (new_flags, OSPF_FLAG_ABR); |
| 419 | else |
| 420 | UNSET_FLAG (new_flags, OSPF_FLAG_ABR); |
| 421 | break; |
| 422 | default: |
| 423 | break; |
| 424 | } |
| 425 | |
| 426 | if (new_flags != ospf_top->flags) |
| 427 | { |
| 428 | ospf_spf_calculate_schedule (); |
| 429 | if (IS_DEBUG_OSPF_EVENT) |
| 430 | zlog_info ("ospf_check_abr_status(): new router flags: %x",new_flags); |
| 431 | ospf_top->flags = new_flags; |
| 432 | OSPF_TIMER_ON (ospf_top->t_router_lsa_update, |
| 433 | ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | void |
| 438 | ospf_abr_update_aggregate (struct ospf_area_range *range, |
| 439 | struct ospf_route *or) |
| 440 | { |
| 441 | if (IS_DEBUG_OSPF_EVENT) |
| 442 | zlog_info ("ospf_abr_update_aggregate(): Start"); |
| 443 | |
| 444 | if (range->cost_config != -1) |
| 445 | { |
| 446 | if (IS_DEBUG_OSPF_EVENT) |
| 447 | zlog_info ("ospf_abr_update_aggregate(): use configured cost %d", |
| 448 | range->cost_config); |
| 449 | |
| 450 | range->cost = range->cost_config; |
| 451 | } |
| 452 | else |
| 453 | { |
| 454 | if (range->specifics == 0) |
| 455 | range->cost = or->cost; /* 1st time get 1st cost */ |
| 456 | |
| 457 | if (or->cost < range->cost) |
| 458 | { |
| 459 | if (IS_DEBUG_OSPF_EVENT) |
| 460 | zlog_info ("ospf_abr_update_aggregate(): lowest cost, update"); |
| 461 | |
| 462 | range->cost = or->cost; |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | range->specifics++; |
| 467 | } |
| 468 | |
| 469 | static void |
| 470 | set_metric (struct ospf_lsa *lsa, u_int32_t metric) |
| 471 | { |
| 472 | struct summary_lsa *header; |
| 473 | u_char *mp; |
| 474 | metric = htonl (metric); |
| 475 | mp = (char *) &metric; |
| 476 | mp++; |
| 477 | header = (struct summary_lsa *) lsa->data; |
| 478 | memcpy(header->metric, mp, 3); |
| 479 | } |
| 480 | |
| 481 | #ifdef HAVE_NSSA |
| 482 | int |
| 483 | ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost, |
| 484 | struct ospf_area *area) |
| 485 | { |
| 486 | /* The Type-7 is tested against the aggregated prefix and forwarded |
| 487 | for lsa installation and flooding */ |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | /* ospf_abr_translate_nssa */ |
| 492 | int |
| 493 | ospf_abr_translate_nssa (struct ospf_lsa *lsa, void *p_arg, int int_arg) |
| 494 | { |
| 495 | /* Incoming Type-7 or later aggregated Type-7 |
| 496 | |
| 497 | LSA is skipped if P-bit is off. |
| 498 | LSA is aggregated if within range. |
| 499 | |
| 500 | The Type-7 is translated, Installed/Approved as a Type-5 into |
| 501 | global LSDB, then Flooded through AS |
| 502 | |
| 503 | Later, any Unapproved Translated Type-5's are flushed/discarded */ |
| 504 | |
| 505 | struct ospf_lsa *dup; |
| 506 | |
| 507 | if (! CHECK_FLAG (lsa->data->options, OSPF_OPTION_NP)) |
| 508 | { |
| 509 | if (IS_DEBUG_OSPF_NSSA) |
| 510 | zlog_info ("ospf_abr_nssa(): P-bit off, NO Translation"); |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | if (IS_DEBUG_OSPF_NSSA) |
| 515 | zlog_info ("ospf_abr_nssa(): TRANSLATING 7 to 5"); |
| 516 | |
| 517 | /* No more P-bit. */ |
| 518 | /* UNSET_FLAG (lsa->data->options, OSPF_OPTION_NP); */ |
| 519 | |
| 520 | /* Area where Aggregate testing will be inserted, just like summary |
| 521 | advertisements */ |
| 522 | /* ospf_abr_check_nssa_range (p_arg, lsa-> cost, lsa -> area); */ |
| 523 | |
| 524 | /* Follow thru here means no aggregation */ |
| 525 | dup = ospf_lsa_dup (lsa); /* keep LSDB intact, lock = 1 */ |
| 526 | |
| 527 | SET_FLAG (dup->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7 */ |
| 528 | SET_FLAG (dup->flags, OSPF_LSA_APPROVED); /* So, do not remove it */ |
| 529 | |
| 530 | dup->data->type = OSPF_AS_EXTERNAL_LSA; /* make Type-5 */ |
| 531 | |
| 532 | ospf_lsa_checksum (dup->data); |
| 533 | |
| 534 | ospf_lsa_install (NULL, dup); /* Install this Type-5 into LSDB, Lock = 2. */ |
| 535 | |
| 536 | ospf_flood_through_as (NULL, dup); /* flood non-NSSA/STUB areas */ |
| 537 | |
| 538 | /* This translated Type-5 will go to all non-NSSA areas connected to |
| 539 | this ABR; The Type-5 could come from any of the NSSA's connected |
| 540 | to this ABR. */ |
| 541 | |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | void |
| 546 | ospf_abr_translate_nssa_range (struct prefix_ipv4 *p, u_int32_t cost) |
| 547 | { |
| 548 | /* The Type-7 is created from the aggregated prefix and forwarded |
| 549 | for lsa installation and flooding... to be added... */ |
| 550 | } |
| 551 | #endif /* HAVE_NSSA */ |
| 552 | |
| 553 | void |
| 554 | ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, |
| 555 | struct ospf_area *area) |
| 556 | { |
| 557 | struct ospf_lsa *lsa, *old = NULL; |
| 558 | struct summary_lsa *sl = NULL; |
| 559 | |
| 560 | if (IS_DEBUG_OSPF_EVENT) |
| 561 | zlog_info ("ospf_abr_announce_network_to_area(): Start"); |
| 562 | |
| 563 | old = OSPF_SUMMARY_LSA_SELF_FIND_BY_PREFIX (area, p); |
| 564 | |
| 565 | if (old) |
| 566 | { |
| 567 | if (IS_DEBUG_OSPF_EVENT) |
| 568 | zlog_info ("ospf_abr_announce_network_to_area(): old summary found"); |
| 569 | sl = (struct summary_lsa *) old->data; |
| 570 | |
| 571 | if (IS_DEBUG_OSPF_EVENT) |
| 572 | zlog_info ("ospf_abr_announce_network_to_area(): " |
| 573 | "old metric: %d, new metric: %d", |
| 574 | GET_METRIC (sl->metric), cost); |
| 575 | } |
| 576 | |
| 577 | if (old && (GET_METRIC (sl->metric) == cost)) |
| 578 | { |
| 579 | if (IS_DEBUG_OSPF_EVENT) |
| 580 | zlog_info ("ospf_abr_announce_network_to_area(): " |
| 581 | "old summary approved"); |
| 582 | SET_FLAG (old->flags, OSPF_LSA_APPROVED); |
| 583 | } |
| 584 | else |
| 585 | { |
| 586 | if (IS_DEBUG_OSPF_EVENT) |
| 587 | zlog_info ("ospf_abr_announce_network_to_area(): " |
| 588 | "creating new summary"); |
| 589 | if (old) |
| 590 | { |
| 591 | |
| 592 | set_metric (old, cost); |
| 593 | lsa = ospf_summary_lsa_refresh (old); |
| 594 | /* This will flood through area. */ |
| 595 | } |
| 596 | else |
| 597 | { |
| 598 | lsa = ospf_summary_lsa_originate (p, cost, area); |
| 599 | /* This will flood through area. */ |
| 600 | } |
| 601 | |
| 602 | |
| 603 | SET_FLAG (lsa->flags, OSPF_LSA_APPROVED); |
| 604 | if (IS_DEBUG_OSPF_EVENT) |
| 605 | zlog_info ("ospf_abr_announce_network_to_area(): " |
| 606 | "flooding new version of summary"); |
| 607 | |
| 608 | #ifndef HAVE_NSSA |
| 609 | ospf_flood_through_area (area, NULL, lsa); |
| 610 | #endif /* ! HAVE_NSSA */ |
| 611 | } |
| 612 | |
| 613 | if (IS_DEBUG_OSPF_EVENT) |
| 614 | zlog_info ("ospf_abr_announce_network_to_area(): Stop"); |
| 615 | } |
| 616 | |
| 617 | int |
| 618 | ospf_abr_nexthops_belong_to_area (struct ospf_route *or, |
| 619 | struct ospf_area *area) |
| 620 | { |
| 621 | listnode node; |
| 622 | |
| 623 | for (node = listhead (or->path); node; nextnode (node)) |
| 624 | { |
| 625 | struct ospf_path *path = node->data; |
| 626 | struct ospf_interface *oi = path->oi; |
| 627 | |
| 628 | if (oi != NULL) |
| 629 | if (oi->area == area) |
| 630 | return 1; |
| 631 | } |
| 632 | |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | int |
| 637 | ospf_abr_should_accept (struct prefix *p, struct ospf_area *area) |
| 638 | { |
| 639 | if (IMPORT_NAME (area)) |
| 640 | { |
| 641 | if (IMPORT_LIST (area) == NULL) |
| 642 | IMPORT_LIST (area) = access_list_lookup (AFI_IP, IMPORT_NAME (area)); |
| 643 | |
| 644 | if (IMPORT_LIST (area)) |
| 645 | if (access_list_apply (IMPORT_LIST (area), p) == FILTER_DENY) |
| 646 | return 0; |
| 647 | } |
| 648 | |
| 649 | return 1; |
| 650 | } |
| 651 | |
| 652 | int |
| 653 | ospf_abr_plist_in_check (struct ospf_area *area, struct ospf_route *or, |
| 654 | struct prefix *p) |
| 655 | { |
| 656 | if (PREFIX_NAME_IN (area)) |
| 657 | { |
| 658 | if (PREFIX_LIST_IN (area) == NULL) |
| 659 | PREFIX_LIST_IN (area) = prefix_list_lookup (AFI_IP, |
| 660 | PREFIX_NAME_IN (area)); |
| 661 | if (PREFIX_LIST_IN (area)) |
| 662 | if (prefix_list_apply (PREFIX_LIST_IN (area), p) != PREFIX_PERMIT) |
| 663 | return 0; |
| 664 | } |
| 665 | return 1; |
| 666 | } |
| 667 | |
| 668 | int |
| 669 | ospf_abr_plist_out_check (struct ospf_area *area, struct ospf_route *or, |
| 670 | struct prefix *p) |
| 671 | { |
| 672 | if (PREFIX_NAME_OUT (area)) |
| 673 | { |
| 674 | if (PREFIX_LIST_OUT (area) == NULL) |
| 675 | PREFIX_LIST_OUT (area) = prefix_list_lookup (AFI_IP, |
| 676 | PREFIX_NAME_OUT (area)); |
| 677 | if (PREFIX_LIST_OUT (area)) |
| 678 | if (prefix_list_apply (PREFIX_LIST_OUT (area), p) != PREFIX_PERMIT) |
| 679 | return 0; |
| 680 | } |
| 681 | return 1; |
| 682 | } |
| 683 | |
| 684 | void |
| 685 | ospf_abr_announce_network (struct route_node *n, struct ospf_route *or) |
| 686 | { |
| 687 | listnode node; |
| 688 | struct ospf_area_range *range; |
| 689 | struct prefix_ipv4 *p; |
| 690 | struct ospf_area *area, *or_area; |
| 691 | |
| 692 | if (IS_DEBUG_OSPF_EVENT) |
| 693 | zlog_info ("ospf_abr_announce_network(): Start"); |
| 694 | p = (struct prefix_ipv4 *) &n->p; |
| 695 | |
| 696 | or_area = ospf_area_lookup_by_area_id (or->u.std.area_id); |
| 697 | assert (or_area); |
| 698 | |
| 699 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 700 | { |
| 701 | area = getdata (node); |
| 702 | |
| 703 | if (IS_DEBUG_OSPF_EVENT) |
| 704 | zlog_info ("ospf_abr_announce_network(): looking at area %s", |
| 705 | inet_ntoa (area->area_id)); |
| 706 | |
| 707 | if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id)) |
| 708 | continue; |
| 709 | |
| 710 | if (ospf_abr_nexthops_belong_to_area (or, area)) |
| 711 | continue; |
| 712 | |
| 713 | if (!ospf_abr_should_accept (&n->p, area)) |
| 714 | { |
| 715 | if (IS_DEBUG_OSPF_EVENT) |
| 716 | zlog_info ("ospf_abr_announce_network(): " |
| 717 | "prefix %s/%d was denied by import-list", |
| 718 | inet_ntoa (p->prefix), p->prefixlen); |
| 719 | continue; |
| 720 | } |
| 721 | |
| 722 | if (!ospf_abr_plist_in_check (area, or, &n->p)) |
| 723 | { |
| 724 | if (IS_DEBUG_OSPF_EVENT) |
| 725 | zlog_info ("ospf_abr_announce_network(): " |
| 726 | "prefix %s/%d was denied by prefix-list", |
| 727 | inet_ntoa (p->prefix), p->prefixlen); |
| 728 | continue; |
| 729 | } |
| 730 | |
| 731 | if (area->external_routing != OSPF_AREA_DEFAULT && area->no_summary) |
| 732 | { |
| 733 | if (IS_DEBUG_OSPF_EVENT) |
| 734 | zlog_info ("ospf_abr_announce_network(): " |
| 735 | "area %s is stub and no_summary", |
| 736 | inet_ntoa (area->area_id)); |
| 737 | continue; |
| 738 | } |
| 739 | |
| 740 | if (or->path_type == OSPF_PATH_INTER_AREA) |
| 741 | { |
| 742 | if (IS_DEBUG_OSPF_EVENT) |
| 743 | zlog_info ("ospf_abr_announce_network(): this is " |
| 744 | "inter-area route to %s/%d", |
| 745 | inet_ntoa (p->prefix), p->prefixlen); |
| 746 | |
| 747 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 748 | ospf_abr_announce_network_to_area (p, or->cost, area); |
| 749 | } |
| 750 | |
| 751 | if (or->path_type == OSPF_PATH_INTRA_AREA) |
| 752 | { |
| 753 | if (IS_DEBUG_OSPF_EVENT) |
| 754 | zlog_info ("ospf_abr_announce_network(): " |
| 755 | "this is intra-area route to %s/%d", |
| 756 | inet_ntoa (p->prefix), p->prefixlen); |
| 757 | if ((range = ospf_area_range_match (or_area, p)) && |
| 758 | !ospf_area_is_transit (area)) |
| 759 | ospf_abr_update_aggregate (range, or); |
| 760 | else |
| 761 | ospf_abr_announce_network_to_area (p, or->cost, area); |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | int |
| 767 | ospf_abr_should_announce (struct prefix *p, struct ospf_route *or) |
| 768 | { |
| 769 | struct ospf_area *area = ospf_area_lookup_by_area_id (or->u.std.area_id); |
| 770 | |
| 771 | assert (area); |
| 772 | |
| 773 | if (EXPORT_NAME (area)) |
| 774 | { |
| 775 | if (EXPORT_LIST (area) == NULL) |
| 776 | EXPORT_LIST (area) = access_list_lookup (AFI_IP, EXPORT_NAME (area)); |
| 777 | |
| 778 | if (EXPORT_LIST (area)) |
| 779 | if (access_list_apply (EXPORT_LIST (area), p) == FILTER_DENY) |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | return 1; |
| 784 | } |
| 785 | |
| 786 | #ifdef HAVE_NSSA |
| 787 | void |
| 788 | ospf_abr_process_nssa_translates () |
| 789 | { |
| 790 | /* Scan through all NSSA_LSDB records for all areas; |
| 791 | |
| 792 | If P-bit is on, translate all Type-7's to 5's and aggregate or |
| 793 | flood install as approved in Type-5 LSDB with XLATE Flag on |
| 794 | later, do same for all aggregates... At end, DISCARD all |
| 795 | remaining UNAPPROVED Type-5's (Aggregate is for future ) */ |
| 796 | listnode node; |
| 797 | struct ospf_area *area; |
| 798 | |
| 799 | if (IS_DEBUG_OSPF_NSSA) |
| 800 | zlog_info ("ospf_abr_process_nssa_translates(): Start"); |
| 801 | |
| 802 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 803 | { |
| 804 | area = getdata (node); |
| 805 | |
| 806 | if (! area->NSSATranslator) |
| 807 | continue; /* skip if not translator */ |
| 808 | |
| 809 | if (area->external_routing != OSPF_AREA_NSSA) |
| 810 | continue; /* skip if not Nssa Area */ |
| 811 | |
| 812 | if (IS_DEBUG_OSPF_NSSA) |
| 813 | zlog_info ("ospf_abr_process_nssa_translates(): " |
| 814 | "looking at area %s", inet_ntoa (area->area_id)); |
| 815 | |
| 816 | foreach_lsa (NSSA_LSDB (area), area, 0, ospf_abr_translate_nssa); |
| 817 | } |
| 818 | |
| 819 | if (IS_DEBUG_OSPF_NSSA) |
| 820 | zlog_info ("ospf_abr_process_nssa_translates(): Stop"); |
| 821 | |
| 822 | } |
| 823 | #endif /* HAVE_NSSA */ |
| 824 | |
| 825 | void |
| 826 | ospf_abr_process_network_rt (struct route_table *rt) |
| 827 | { |
| 828 | struct route_node *rn; |
| 829 | struct ospf_route *or; |
| 830 | struct ospf_area *area; |
| 831 | |
| 832 | if (IS_DEBUG_OSPF_EVENT) |
| 833 | zlog_info ("ospf_abr_process_network_rt(): Start"); |
| 834 | |
| 835 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 836 | { |
| 837 | if ((or = rn->info) == NULL) |
| 838 | continue; |
| 839 | |
| 840 | if (!(area = ospf_area_lookup_by_area_id (or->u.std.area_id))) |
| 841 | { |
| 842 | if (IS_DEBUG_OSPF_EVENT) |
| 843 | zlog_info ("ospf_abr_process_network_rt(): area %s no longer exists", |
| 844 | inet_ntoa (or->u.std.area_id)); |
| 845 | continue; |
| 846 | } |
| 847 | |
| 848 | if (IS_DEBUG_OSPF_EVENT) |
| 849 | zlog_info ("ospf_abr_process_network_rt(): this is a route to %s/%d", |
| 850 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 851 | if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL) |
| 852 | { |
| 853 | if (IS_DEBUG_OSPF_EVENT) |
| 854 | zlog_info ("ospf_abr_process_network_rt(): " |
| 855 | "this is an External router, skipping"); |
| 856 | continue; |
| 857 | } |
| 858 | |
| 859 | if (or->cost >= OSPF_LS_INFINITY) |
| 860 | { |
| 861 | if (IS_DEBUG_OSPF_EVENT) |
| 862 | zlog_info ("ospf_abr_process_network_rt():" |
| 863 | " this route's cost is infinity, skipping"); |
| 864 | continue; |
| 865 | } |
| 866 | |
| 867 | if (or->type == OSPF_DESTINATION_DISCARD) |
| 868 | { |
| 869 | if (IS_DEBUG_OSPF_EVENT) |
| 870 | zlog_info ("ospf_abr_process_network_rt():" |
| 871 | " this is a discard entry, skipping"); |
| 872 | continue; |
| 873 | } |
| 874 | |
| 875 | if (or->path_type == OSPF_PATH_INTRA_AREA && |
| 876 | !ospf_abr_should_announce (&rn->p, or)) |
| 877 | { |
| 878 | if (IS_DEBUG_OSPF_EVENT) |
| 879 | zlog_info("ospf_abr_process_network_rt(): denied by export-list"); |
| 880 | continue; |
| 881 | } |
| 882 | |
| 883 | if (or->path_type == OSPF_PATH_INTRA_AREA && |
| 884 | !ospf_abr_plist_out_check (area, or, &rn->p)) |
| 885 | { |
| 886 | if (IS_DEBUG_OSPF_EVENT) |
| 887 | zlog_info("ospf_abr_process_network_rt(): denied by prefix-list"); |
| 888 | continue; |
| 889 | } |
| 890 | |
| 891 | if ((or->path_type == OSPF_PATH_INTER_AREA) && |
| 892 | !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) |
| 893 | { |
| 894 | if (IS_DEBUG_OSPF_EVENT) |
| 895 | zlog_info ("ospf_abr_process_network_rt():" |
| 896 | " this is route is not backbone one, skipping"); |
| 897 | continue; |
| 898 | } |
| 899 | |
| 900 | |
| 901 | if ((ospf_top->abr_type == OSPF_ABR_CISCO) || |
| 902 | (ospf_top->abr_type == OSPF_ABR_IBM)) |
| 903 | |
| 904 | if (!ospf_act_bb_connection () && |
| 905 | or->path_type != OSPF_PATH_INTRA_AREA) |
| 906 | { |
| 907 | if (IS_DEBUG_OSPF_EVENT) |
| 908 | zlog_info ("ospf_abr_process_network_rt(): ALT ABR: " |
| 909 | "No BB connection, skip not intra-area routes"); |
| 910 | continue; |
| 911 | } |
| 912 | |
| 913 | if (IS_DEBUG_OSPF_EVENT) |
| 914 | zlog_info ("ospf_abr_process_network_rt(): announcing"); |
| 915 | ospf_abr_announce_network (rn, or); |
| 916 | } |
| 917 | |
| 918 | if (IS_DEBUG_OSPF_EVENT) |
| 919 | zlog_info ("ospf_abr_process_network_rt(): Stop"); |
| 920 | } |
| 921 | |
| 922 | void |
| 923 | ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost, |
| 924 | struct ospf_area *area) |
| 925 | { |
| 926 | struct ospf_lsa *lsa, *old = NULL; |
| 927 | struct summary_lsa *slsa = NULL; |
| 928 | |
| 929 | if (IS_DEBUG_OSPF_EVENT) |
| 930 | zlog_info ("ospf_abr_announce_rtr_to_area(): Start"); |
| 931 | |
| 932 | old = OSPF_SUMMARY_ASBR_LSA_SELF_FIND_BY_PREFIX (area, p); |
| 933 | /* old = ospf_find_self_summary_asbr_lsa_by_prefix (area, p); */ |
| 934 | |
| 935 | if (old) |
| 936 | { |
| 937 | if (IS_DEBUG_OSPF_EVENT) |
| 938 | zlog_info ("ospf_abr_announce_rtr_to_area(): old summary found"); |
| 939 | slsa = (struct summary_lsa *) old->data; |
| 940 | |
| 941 | if (IS_DEBUG_OSPF_EVENT) |
| 942 | zlog_info ("ospf_abr_announce_network_to_area(): " |
| 943 | "old metric: %d, new metric: %d", |
| 944 | GET_METRIC (slsa->metric), cost); |
| 945 | } |
| 946 | |
| 947 | if (old && (GET_METRIC (slsa->metric) == cost)) |
| 948 | { |
| 949 | if (IS_DEBUG_OSPF_EVENT) |
| 950 | zlog_info ("ospf_abr_announce_rtr_to_area(): old summary approved"); |
| 951 | SET_FLAG (old->flags, OSPF_LSA_APPROVED); |
| 952 | } |
| 953 | else |
| 954 | { |
| 955 | if (IS_DEBUG_OSPF_EVENT) |
| 956 | zlog_info ("ospf_abr_announce_rtr_to_area(): 2.2"); |
| 957 | |
| 958 | if (old) |
| 959 | { |
| 960 | set_metric (old, cost); |
| 961 | lsa = ospf_summary_asbr_lsa_refresh (old); |
| 962 | } |
| 963 | else |
| 964 | lsa = ospf_summary_asbr_lsa_originate (p, cost, area); |
| 965 | |
| 966 | if (IS_DEBUG_OSPF_EVENT) |
| 967 | zlog_info ("ospf_abr_announce_rtr_to_area(): " |
| 968 | "flooding new version of summary"); |
| 969 | /* |
| 970 | zlog_info ("ospf_abr_announce_rtr_to_area(): creating new summary"); |
| 971 | lsa = ospf_summary_asbr_lsa (p, cost, area, old); */ |
| 972 | |
| 973 | SET_FLAG (lsa->flags, OSPF_LSA_APPROVED); |
| 974 | /* ospf_flood_through_area (area, NULL, lsa);*/ |
| 975 | } |
| 976 | |
| 977 | if (IS_DEBUG_OSPF_EVENT) |
| 978 | zlog_info ("ospf_abr_announce_rtr_to_area(): Stop"); |
| 979 | } |
| 980 | |
| 981 | |
| 982 | void |
| 983 | ospf_abr_announce_rtr (struct prefix_ipv4 *p, struct ospf_route *or) |
| 984 | { |
| 985 | listnode node; |
| 986 | struct ospf_area *area; |
| 987 | |
| 988 | if (IS_DEBUG_OSPF_EVENT) |
| 989 | zlog_info ("ospf_abr_announce_rtr(): Start"); |
| 990 | |
| 991 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 992 | { |
| 993 | area = getdata (node); |
| 994 | |
| 995 | if (IS_DEBUG_OSPF_EVENT) |
| 996 | zlog_info ("ospf_abr_announce_rtr(): looking at area %s", |
| 997 | inet_ntoa (area->area_id)); |
| 998 | |
| 999 | if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id)) |
| 1000 | continue; |
| 1001 | |
| 1002 | if (ospf_abr_nexthops_belong_to_area (or, area)) |
| 1003 | continue; |
| 1004 | |
| 1005 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 1006 | { |
| 1007 | if (IS_DEBUG_OSPF_EVENT) |
| 1008 | zlog_info ("ospf_abr_announce_network(): " |
| 1009 | "area %s doesn't support external routing", |
| 1010 | inet_ntoa(area->area_id)); |
| 1011 | continue; |
| 1012 | } |
| 1013 | |
| 1014 | if (or->path_type == OSPF_PATH_INTER_AREA) |
| 1015 | { |
| 1016 | if (IS_DEBUG_OSPF_EVENT) |
| 1017 | zlog_info ("ospf_abr_announce_rtr(): " |
| 1018 | "this is inter-area route to %s", inet_ntoa (p->prefix)); |
| 1019 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 1020 | ospf_abr_announce_rtr_to_area (p, or->cost, area); |
| 1021 | } |
| 1022 | |
| 1023 | if (or->path_type == OSPF_PATH_INTRA_AREA) |
| 1024 | { |
| 1025 | if (IS_DEBUG_OSPF_EVENT) |
| 1026 | zlog_info ("ospf_abr_announce_rtr(): " |
| 1027 | "this is intra-area route to %s", inet_ntoa (p->prefix)); |
| 1028 | ospf_abr_announce_rtr_to_area (p, or->cost, area); |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | if (IS_DEBUG_OSPF_EVENT) |
| 1033 | zlog_info ("ospf_abr_announce_rtr(): Stop"); |
| 1034 | } |
| 1035 | |
| 1036 | void |
| 1037 | ospf_abr_process_router_rt (struct route_table *rt) |
| 1038 | { |
| 1039 | struct route_node *rn; |
| 1040 | struct ospf_route *or; |
| 1041 | struct list *l; |
| 1042 | |
| 1043 | if (IS_DEBUG_OSPF_EVENT) |
| 1044 | zlog_info ("ospf_abr_process_router_rt(): Start"); |
| 1045 | |
| 1046 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 1047 | { |
| 1048 | listnode node; |
| 1049 | char flag = 0; |
| 1050 | struct ospf_route *best = NULL; |
| 1051 | |
| 1052 | if (rn->info == NULL) |
| 1053 | continue; |
| 1054 | |
| 1055 | l = rn->info; |
| 1056 | |
| 1057 | if (IS_DEBUG_OSPF_EVENT) |
| 1058 | zlog_info ("ospf_abr_process_router_rt(): this is a route to %s", |
| 1059 | inet_ntoa (rn->p.u.prefix4)); |
| 1060 | |
| 1061 | for (node = listhead (l); node; nextnode (node)) |
| 1062 | { |
| 1063 | or = getdata (node); |
| 1064 | if (or == NULL) |
| 1065 | continue; |
| 1066 | |
| 1067 | if (!ospf_area_lookup_by_area_id (or->u.std.area_id)) |
| 1068 | { |
| 1069 | if (IS_DEBUG_OSPF_EVENT) |
| 1070 | zlog_info ("ospf_abr_process_router_rt(): area %s no longer exists", |
| 1071 | inet_ntoa (or->u.std.area_id)); |
| 1072 | continue; |
| 1073 | } |
| 1074 | |
| 1075 | |
| 1076 | if (!CHECK_FLAG (or->u.std.flags, ROUTER_LSA_EXTERNAL)) |
| 1077 | { |
| 1078 | if (IS_DEBUG_OSPF_EVENT) |
| 1079 | zlog_info ("ospf_abr_process_router_rt(): " |
| 1080 | "This is not an ASBR, skipping"); |
| 1081 | continue; |
| 1082 | } |
| 1083 | |
| 1084 | if (!flag) |
| 1085 | { |
| 1086 | best = ospf_find_asbr_route (rt, (struct prefix_ipv4 *) &rn->p); |
| 1087 | flag = 1; |
| 1088 | } |
| 1089 | |
| 1090 | if (best == NULL) |
| 1091 | continue; |
| 1092 | |
| 1093 | if (or != best) |
| 1094 | { |
| 1095 | if (IS_DEBUG_OSPF_EVENT) |
| 1096 | zlog_info ("ospf_abr_process_router_rt(): " |
| 1097 | "This route is not the best among possible, skipping"); |
| 1098 | continue; |
| 1099 | } |
| 1100 | |
| 1101 | if (or->path_type == OSPF_PATH_INTER_AREA && |
| 1102 | !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) |
| 1103 | { |
| 1104 | if (IS_DEBUG_OSPF_EVENT) |
| 1105 | zlog_info ("ospf_abr_process_router_rt(): " |
| 1106 | "This route is not a backbone one, skipping"); |
| 1107 | continue; |
| 1108 | } |
| 1109 | |
| 1110 | if (or->cost >= OSPF_LS_INFINITY) |
| 1111 | { |
| 1112 | if (IS_DEBUG_OSPF_EVENT) |
| 1113 | zlog_info ("ospf_abr_process_router_rt(): " |
| 1114 | "This route has LS_INFINITY metric, skipping"); |
| 1115 | continue; |
| 1116 | } |
| 1117 | |
| 1118 | if (ospf_top->abr_type == OSPF_ABR_CISCO || |
| 1119 | ospf_top->abr_type == OSPF_ABR_IBM) |
| 1120 | if (!ospf_act_bb_connection () && |
| 1121 | or->path_type != OSPF_PATH_INTRA_AREA) |
| 1122 | { |
| 1123 | if (IS_DEBUG_OSPF_EVENT) |
| 1124 | zlog_info("ospf_abr_process_network_rt(): ALT ABR: " |
| 1125 | "No BB connection, skip not intra-area routes"); |
| 1126 | continue; |
| 1127 | } |
| 1128 | |
| 1129 | ospf_abr_announce_rtr ((struct prefix_ipv4 *) &rn->p, or); |
| 1130 | |
| 1131 | } |
| 1132 | |
| 1133 | } |
| 1134 | |
| 1135 | if (IS_DEBUG_OSPF_EVENT) |
| 1136 | zlog_info ("ospf_abr_process_router_rt(): Stop"); |
| 1137 | } |
| 1138 | |
| 1139 | #ifdef HAVE_NSSA |
| 1140 | int |
| 1141 | ospf_abr_unapprove_translates_apply (struct ospf_lsa *lsa, void *p_arg, |
| 1142 | int int_arg) |
| 1143 | { |
| 1144 | /* Could be a mix of Normal Type-5's, self-originated, or Type-7s |
| 1145 | that are Locally ABR Translated */ |
| 1146 | |
| 1147 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 1148 | UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED); |
| 1149 | |
| 1150 | return 0; |
| 1151 | } |
| 1152 | |
| 1153 | void |
| 1154 | ospf_abr_unapprove_translates () /* For NSSA Translations */ |
| 1155 | { |
| 1156 | if (IS_DEBUG_OSPF_NSSA) |
| 1157 | zlog_info ("ospf_abr_unapprove_translates(): Start"); |
| 1158 | |
| 1159 | /* NSSA Translator is not checked, because it may have gone away, |
| 1160 | and we would want to flush any residuals anyway */ |
| 1161 | |
| 1162 | foreach_lsa (EXTERNAL_LSDB (ospf_top), NULL, 0, |
| 1163 | ospf_abr_unapprove_translates_apply); |
| 1164 | |
| 1165 | if (IS_DEBUG_OSPF_NSSA) |
| 1166 | zlog_info ("ospf_abr_unapprove_translates(): Stop"); |
| 1167 | } |
| 1168 | #endif /* HAVE_NSSA */ |
| 1169 | |
| 1170 | int |
| 1171 | ospf_abr_unapprove_summaries_apply (struct ospf_lsa *lsa, void *p_arg, |
| 1172 | int int_arg) |
| 1173 | { |
| 1174 | if (ospf_lsa_is_self_originated (lsa)) |
| 1175 | UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED); |
| 1176 | |
| 1177 | return 0; |
| 1178 | } |
| 1179 | |
| 1180 | void |
| 1181 | ospf_abr_unapprove_summaries () |
| 1182 | { |
| 1183 | listnode node; |
| 1184 | struct ospf_area *area; |
| 1185 | |
| 1186 | if (IS_DEBUG_OSPF_EVENT) |
| 1187 | zlog_info ("ospf_abr_unapprove_summaries(): Start"); |
| 1188 | |
| 1189 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1190 | { |
| 1191 | area = getdata (node); |
| 1192 | foreach_lsa (SUMMARY_LSDB (area), NULL, 0, |
| 1193 | ospf_abr_unapprove_summaries_apply); |
| 1194 | foreach_lsa (ASBR_SUMMARY_LSDB (area), NULL, 0, |
| 1195 | ospf_abr_unapprove_summaries_apply); |
| 1196 | } |
| 1197 | |
| 1198 | if (IS_DEBUG_OSPF_EVENT) |
| 1199 | zlog_info ("ospf_abr_unapprove_summaries(): Stop"); |
| 1200 | } |
| 1201 | |
| 1202 | void |
| 1203 | ospf_abr_prepare_aggregates () |
| 1204 | { |
| 1205 | listnode node; |
| 1206 | struct route_node *rn; |
| 1207 | struct ospf_area_range *range; |
| 1208 | |
| 1209 | if (IS_DEBUG_OSPF_EVENT) |
| 1210 | zlog_info ("ospf_abr_prepare_aggregates(): Start"); |
| 1211 | |
| 1212 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1213 | { |
| 1214 | struct ospf_area *area = getdata (node); |
| 1215 | |
| 1216 | for (rn = route_top (area->ranges); rn; rn = route_next (rn)) |
| 1217 | if ((range = rn->info) != NULL) |
| 1218 | { |
| 1219 | range->cost = 0; |
| 1220 | range->specifics = 0; |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | if (IS_DEBUG_OSPF_EVENT) |
| 1225 | zlog_info ("ospf_abr_prepare_aggregates(): Stop"); |
| 1226 | } |
| 1227 | |
| 1228 | void |
| 1229 | ospf_abr_announce_aggregates () |
| 1230 | { |
| 1231 | struct ospf_area *area, *ar; |
| 1232 | struct ospf_area_range *range; |
| 1233 | struct route_node *rn; |
| 1234 | struct prefix_ipv4 p; |
| 1235 | listnode node, n; |
| 1236 | |
| 1237 | if (IS_DEBUG_OSPF_EVENT) |
| 1238 | zlog_info ("ospf_abr_announce_aggregates(): Start"); |
| 1239 | |
| 1240 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1241 | { |
| 1242 | area = getdata (node); |
| 1243 | |
| 1244 | if (IS_DEBUG_OSPF_EVENT) |
| 1245 | zlog_info ("ospf_abr_announce_aggregates(): looking at area %s", |
| 1246 | inet_ntoa (area->area_id)); |
| 1247 | |
| 1248 | for (rn = route_top (area->ranges); rn; rn = route_next (rn)) |
| 1249 | if ((range = rn->info)) |
| 1250 | { |
| 1251 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 1252 | { |
| 1253 | if (IS_DEBUG_OSPF_EVENT) |
| 1254 | zlog_info ("ospf_abr_announce_aggregates():" |
| 1255 | " discarding suppress-ranges"); |
| 1256 | continue; |
| 1257 | } |
| 1258 | |
| 1259 | p.family = AF_INET; |
| 1260 | p.prefix = range->addr; |
| 1261 | p.prefixlen = range->masklen; |
| 1262 | |
| 1263 | if (IS_DEBUG_OSPF_EVENT) |
| 1264 | zlog_info ("ospf_abr_announce_aggregates():" |
| 1265 | " this is range: %s/%d", |
| 1266 | inet_ntoa (p.prefix), p.prefixlen); |
| 1267 | |
| 1268 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 1269 | { |
| 1270 | p.family = AF_INET; |
| 1271 | p.prefix = range->subst_addr; |
| 1272 | p.prefixlen = range->subst_masklen; |
| 1273 | } |
| 1274 | |
| 1275 | if (range->specifics) |
| 1276 | { |
| 1277 | if (IS_DEBUG_OSPF_EVENT) |
| 1278 | zlog_info ("ospf_abr_announce_aggregates(): active range"); |
| 1279 | |
| 1280 | for (n = listhead (ospf_top->areas); n; nextnode (n)) |
| 1281 | { |
| 1282 | ar = getdata (n); |
| 1283 | if (ar == area) |
| 1284 | continue; |
| 1285 | |
| 1286 | /* We do not check nexthops here, because |
| 1287 | intra-area routes can be associated with |
| 1288 | one area only */ |
| 1289 | |
| 1290 | /* backbone routes are not summarized |
| 1291 | when announced into transit areas */ |
| 1292 | |
| 1293 | if (ospf_area_is_transit (ar) && |
| 1294 | OSPF_IS_AREA_BACKBONE (area)) |
| 1295 | { |
| 1296 | if (IS_DEBUG_OSPF_EVENT) |
| 1297 | zlog_info ("ospf_abr_announce_aggregates(): Skipping " |
| 1298 | "announcement of BB aggregate into" |
| 1299 | " a transit area"); |
| 1300 | continue; |
| 1301 | } |
| 1302 | ospf_abr_announce_network_to_area (&p, range->cost, ar); |
| 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | if (IS_DEBUG_OSPF_EVENT) |
| 1309 | zlog_info ("ospf_abr_announce_aggregates(): Stop"); |
| 1310 | } |
| 1311 | |
| 1312 | #ifdef HAVE_NSSA |
| 1313 | void |
| 1314 | ospf_abr_send_nssa_aggregates () /* temporarily turned off */ |
| 1315 | { |
| 1316 | listnode node; /*, n; */ |
| 1317 | struct ospf_area *area; /*, *ar; */ |
| 1318 | struct route_node *rn; |
| 1319 | struct ospf_area_range *range; |
| 1320 | struct prefix_ipv4 p; |
| 1321 | |
| 1322 | if (IS_DEBUG_OSPF_NSSA) |
| 1323 | zlog_info ("ospf_abr_send_nssa_aggregates(): Start"); |
| 1324 | |
| 1325 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1326 | { |
| 1327 | area = getdata (node); |
| 1328 | |
| 1329 | if (! area->NSSATranslator) |
| 1330 | continue; |
| 1331 | |
| 1332 | if (IS_DEBUG_OSPF_NSSA) |
| 1333 | zlog_info ("ospf_abr_send_nssa_aggregates(): looking at area %s", |
| 1334 | inet_ntoa (area->area_id)); |
| 1335 | |
| 1336 | for (rn = route_top (area->ranges); rn; rn = route_next (rn)) |
| 1337 | { |
| 1338 | if (rn->info == NULL) |
| 1339 | continue; |
| 1340 | |
| 1341 | range = rn->info; |
| 1342 | |
| 1343 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 1344 | { |
| 1345 | if (IS_DEBUG_OSPF_NSSA) |
| 1346 | zlog_info ("ospf_abr_send_nssa_aggregates():" |
| 1347 | " discarding suppress-ranges"); |
| 1348 | continue; |
| 1349 | } |
| 1350 | |
| 1351 | p.family = AF_INET; |
| 1352 | p.prefix = range->addr; |
| 1353 | p.prefixlen = range->masklen; |
| 1354 | |
| 1355 | if (IS_DEBUG_OSPF_NSSA) |
| 1356 | zlog_info ("ospf_abr_send_nssa_aggregates():" |
| 1357 | " this is range: %s/%d", |
| 1358 | inet_ntoa (p.prefix), p.prefixlen); |
| 1359 | |
| 1360 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 1361 | { |
| 1362 | p.family = AF_INET; |
| 1363 | p.prefix = range->subst_addr; |
| 1364 | p.prefixlen = range->subst_masklen; |
| 1365 | } |
| 1366 | |
| 1367 | if (range->specifics) |
| 1368 | { |
| 1369 | if (IS_DEBUG_OSPF_NSSA) |
| 1370 | zlog_info ("ospf_abr_send_nssa_aggregates(): active range"); |
| 1371 | |
| 1372 | /* Fetch LSA-Type-7 from aggregate prefix, and then |
| 1373 | translate, Install (as Type-5), Approve, and Flood */ |
| 1374 | ospf_abr_translate_nssa_range (&p, range->cost); |
| 1375 | } /* if (range->specifics)*/ |
| 1376 | } /* all area ranges*/ |
| 1377 | } /* all areas */ |
| 1378 | |
| 1379 | if (IS_DEBUG_OSPF_NSSA) |
| 1380 | zlog_info ("ospf_abr_send_nssa_aggregates(): Stop"); |
| 1381 | } |
| 1382 | |
| 1383 | void |
| 1384 | ospf_abr_announce_nssa_defaults () /* By ABR-Translator */ |
| 1385 | { |
| 1386 | listnode node; |
| 1387 | struct ospf_area *area; |
| 1388 | struct prefix_ipv4 p; |
| 1389 | |
| 1390 | if (! OSPF_IS_ABR) |
| 1391 | return; |
| 1392 | |
| 1393 | if (IS_DEBUG_OSPF_NSSA) |
| 1394 | zlog_info ("ospf_abr_announce_stub_defaults(): Start"); |
| 1395 | |
| 1396 | p.family = AF_INET; |
| 1397 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1398 | p.prefixlen = 0; |
| 1399 | |
| 1400 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1401 | { |
| 1402 | area = getdata (node); |
| 1403 | if (IS_DEBUG_OSPF_NSSA) |
| 1404 | zlog_info ("ospf_abr_announce_nssa_defaults(): looking at area %s", |
| 1405 | inet_ntoa (area->area_id)); |
| 1406 | |
| 1407 | if (area->external_routing != OSPF_AREA_NSSA) |
| 1408 | continue; |
| 1409 | |
| 1410 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 1411 | continue; /* Sanity Check */ |
| 1412 | |
| 1413 | /* if (!TranslatorRole continue V 1.0 look for "always" conf */ |
| 1414 | if (area->NSSATranslator) |
| 1415 | { |
| 1416 | if (IS_DEBUG_OSPF_NSSA) |
| 1417 | zlog_info ("ospf_abr_announce_nssa_defaults(): " |
| 1418 | "announcing 0.0.0.0/0 to this nssa"); |
| 1419 | /* ospf_abr_announce_nssa_asbr_to_as (&p, area->default_cost, area); */ |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | #endif /* HAVE_NSSA */ |
| 1424 | |
| 1425 | void |
| 1426 | ospf_abr_announce_stub_defaults () |
| 1427 | { |
| 1428 | listnode node; |
| 1429 | struct ospf_area *area; |
| 1430 | struct prefix_ipv4 p; |
| 1431 | |
| 1432 | if (! OSPF_IS_ABR) |
| 1433 | return; |
| 1434 | |
| 1435 | if (IS_DEBUG_OSPF_EVENT) |
| 1436 | zlog_info ("ospf_abr_announce_stub_defaults(): Start"); |
| 1437 | |
| 1438 | p.family = AF_INET; |
| 1439 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1440 | p.prefixlen = 0; |
| 1441 | |
| 1442 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1443 | { |
| 1444 | area = getdata (node); |
| 1445 | if (IS_DEBUG_OSPF_EVENT) |
| 1446 | zlog_info ("ospf_abr_announce_stub_defaults(): looking at area %s", |
| 1447 | inet_ntoa (area->area_id)); |
| 1448 | |
| 1449 | #ifdef HAVE_NSSA |
| 1450 | if (area->external_routing != OSPF_AREA_STUB) |
| 1451 | #else /* ! HAVE_NSSA */ |
| 1452 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1453 | #endif /* HAVE_NSSA */ |
| 1454 | continue; |
| 1455 | |
| 1456 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 1457 | continue; /* Sanity Check */ |
| 1458 | |
| 1459 | if (IS_DEBUG_OSPF_EVENT) |
| 1460 | zlog_info ("ospf_abr_announce_stub_defaults(): " |
| 1461 | "announcing 0.0.0.0/0 to this area"); |
| 1462 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1463 | } |
| 1464 | |
| 1465 | if (IS_DEBUG_OSPF_EVENT) |
| 1466 | zlog_info ("ospf_abr_announce_stub_defaults(): Stop"); |
| 1467 | } |
| 1468 | |
| 1469 | #ifdef HAVE_NSSA |
| 1470 | int |
| 1471 | ospf_abr_remove_unapproved_translates_apply (struct ospf_lsa *lsa, void *p_arg, |
| 1472 | int int_arg) |
| 1473 | { |
| 1474 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT) |
| 1475 | && ! CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED)) |
| 1476 | { |
| 1477 | zlog_info ("ospf_abr_remove_unapproved_translates(): " |
| 1478 | "removing unapproved translates, ID: %s", |
| 1479 | inet_ntoa (lsa->data->id)); |
| 1480 | |
| 1481 | /* FLUSH THROUGHOUT AS */ |
| 1482 | ospf_lsa_flush_as (lsa); |
| 1483 | |
| 1484 | /* DISCARD from LSDB */ |
| 1485 | } |
| 1486 | return 0; |
| 1487 | } |
| 1488 | |
| 1489 | void |
| 1490 | ospf_abr_remove_unapproved_translates () /* For NSSA Translations */ |
| 1491 | { |
| 1492 | /* All AREA PROCESS should have APPROVED necessary LSAs */ |
| 1493 | /* Remove any left over and not APPROVED */ |
| 1494 | if (IS_DEBUG_OSPF_NSSA) |
| 1495 | zlog_info ("ospf_abr_remove_unapproved_translates(): Start"); |
| 1496 | |
| 1497 | foreach_lsa (EXTERNAL_LSDB (ospf_top), NULL, 0, |
| 1498 | ospf_abr_remove_unapproved_translates_apply); |
| 1499 | |
| 1500 | if (IS_DEBUG_OSPF_NSSA) |
| 1501 | zlog_info ("ospf_abr_remove_unapproved_translates(): Stop"); |
| 1502 | } |
| 1503 | #endif /* HAVE_NSSA */ |
| 1504 | |
| 1505 | int |
| 1506 | ospf_abr_remove_unapproved_summaries_apply (struct ospf_lsa *lsa, void *p_arg, |
| 1507 | int int_arg) |
| 1508 | { |
| 1509 | struct ospf_area *area; |
| 1510 | |
| 1511 | area = (struct ospf_area *) p_arg; |
| 1512 | |
| 1513 | if (ospf_lsa_is_self_originated (lsa) && |
| 1514 | !CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED)) |
| 1515 | { |
| 1516 | if (IS_DEBUG_OSPF_EVENT) |
| 1517 | zlog_info ("ospf_abr_remove_unapproved_summaries(): " |
| 1518 | "removing unapproved summary, ID: %s", |
| 1519 | inet_ntoa (lsa->data->id)); |
| 1520 | ospf_lsa_flush_area (lsa, area); |
| 1521 | } |
| 1522 | return 0; |
| 1523 | } |
| 1524 | |
| 1525 | void |
| 1526 | ospf_abr_remove_unapproved_summaries () |
| 1527 | { |
| 1528 | listnode node; |
| 1529 | struct ospf_area *area; |
| 1530 | |
| 1531 | if (IS_DEBUG_OSPF_EVENT) |
| 1532 | zlog_info ("ospf_abr_remove_unapproved_summaries(): Start"); |
| 1533 | |
| 1534 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1535 | { |
| 1536 | area = getdata (node); |
| 1537 | |
| 1538 | if (IS_DEBUG_OSPF_EVENT) |
| 1539 | zlog_info ("ospf_abr_remove_unapproved_summaries(): " |
| 1540 | "looking at area %s", inet_ntoa (area->area_id)); |
| 1541 | |
| 1542 | foreach_lsa (SUMMARY_LSDB (area), area, 0, |
| 1543 | ospf_abr_remove_unapproved_summaries_apply); |
| 1544 | foreach_lsa (ASBR_SUMMARY_LSDB (area), area, 0, |
| 1545 | ospf_abr_remove_unapproved_summaries_apply); |
| 1546 | } |
| 1547 | |
| 1548 | if (IS_DEBUG_OSPF_EVENT) |
| 1549 | zlog_info ("ospf_abr_remove_unapproved_summaries(): Stop"); |
| 1550 | } |
| 1551 | |
| 1552 | void |
| 1553 | ospf_abr_manage_discard_routes () |
| 1554 | { |
| 1555 | listnode node; |
| 1556 | struct route_node *rn; |
| 1557 | struct ospf_area *area; |
| 1558 | struct ospf_area_range *range; |
| 1559 | |
| 1560 | for (node = listhead (ospf_top->areas); node; nextnode (node)) |
| 1561 | if ((area = node->data) != NULL) |
| 1562 | for (rn = route_top (area->ranges); rn; rn = route_next (rn)) |
| 1563 | if ((range = rn->info) != NULL) |
| 1564 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 1565 | { |
| 1566 | if (range->specifics) |
| 1567 | ospf_add_discard_route (ospf_top->new_table, area, |
| 1568 | (struct prefix_ipv4 *) &rn->p); |
| 1569 | else |
| 1570 | ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p); |
| 1571 | } |
| 1572 | } |
| 1573 | |
| 1574 | #ifdef HAVE_NSSA |
| 1575 | /* This is the function taking care about ABR NSSA, i.e. NSSA |
| 1576 | Translator, -LSA aggregation and flooding. For all NSSAs |
| 1577 | |
| 1578 | Any SELF-AS-LSA is in the Type-5 LSDB and Type-7 LSDB. These LSA's |
| 1579 | are refreshed from the Type-5 LSDB, installed into the Type-7 LSDB |
| 1580 | with the P-bit set. |
| 1581 | |
| 1582 | Any received Type-5s are legal for an ABR, else illegal for IR. |
| 1583 | Received Type-7s are installed, by area, with incoming P-bit. They |
| 1584 | are flooded; if the Elected NSSA Translator, then P-bit off. |
| 1585 | |
| 1586 | Additionally, this ABR will place "translated type-7's" into the |
| 1587 | Type-5 LSDB in order to keep track of APPROVAL or not. |
| 1588 | |
| 1589 | It will scan through every area, looking for Type-7 LSAs with P-Bit |
| 1590 | SET. The Type-7's are either AS-FLOODED & 5-INSTALLED or |
| 1591 | AGGREGATED. Later, the AGGREGATED LSAs are AS-FLOODED & |
| 1592 | 5-INSTALLED. |
| 1593 | |
| 1594 | 5-INSTALLED is into the Type-5 LSDB; Any UNAPPROVED Type-5 LSAs |
| 1595 | left over are FLUSHED and DISCARDED. |
| 1596 | |
| 1597 | For External Calculations, any NSSA areas use the Type-7 AREA-LSDB, |
| 1598 | any ABR-non-NSSA areas use the Type-5 GLOBAL-LSDB. */ |
| 1599 | |
| 1600 | void |
| 1601 | ospf_abr_nssa_task () /* called only if any_nssa */ |
| 1602 | { |
| 1603 | if (IS_DEBUG_OSPF_NSSA) |
| 1604 | zlog_info ("Check for NSSA-ABR Tasks():"); |
| 1605 | |
| 1606 | if (! OSPF_IS_ABR) |
| 1607 | return; |
| 1608 | |
| 1609 | if (! ospf_top->anyNSSA) |
| 1610 | return; |
| 1611 | |
| 1612 | /* Each area must confirm TranslatorRole */ |
| 1613 | if (IS_DEBUG_OSPF_NSSA) |
| 1614 | zlog_info ("ospf_abr_nssa_task(): Start"); |
| 1615 | |
| 1616 | /* For all Global Entries flagged "local-translate", unset APPROVED */ |
| 1617 | if (IS_DEBUG_OSPF_NSSA) |
| 1618 | zlog_info ("ospf_abr_nssa_task(): unapprove translates"); |
| 1619 | |
| 1620 | ospf_abr_unapprove_translates (); |
| 1621 | |
| 1622 | /* RESET all Ranges in every Area, same as summaries */ |
| 1623 | if (IS_DEBUG_OSPF_NSSA) |
| 1624 | zlog_info ("ospf_abr_nssa_task(): NSSA initialize aggregates"); |
| 1625 | |
| 1626 | /* ospf_abr_prepare_aggregates (); TURNED OFF just for now */ |
| 1627 | |
| 1628 | /* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or |
| 1629 | Aggregate as Type-7 */ |
| 1630 | /* Install or Approve in Type-5 Global LSDB */ |
| 1631 | if (IS_DEBUG_OSPF_NSSA) |
| 1632 | zlog_info ("ospf_abr_nssa_task(): process translates"); |
| 1633 | |
| 1634 | ospf_abr_process_nssa_translates (ospf_top->new_table); |
| 1635 | |
| 1636 | /* Translate/Send any "ranged" aggregates, and also 5-Install and |
| 1637 | Approve */ |
| 1638 | /* Scan Type-7's for aggregates, translate to Type-5's, |
| 1639 | Install/Flood/Approve */ |
| 1640 | if (IS_DEBUG_OSPF_NSSA) |
| 1641 | zlog_info("ospf_abr_nssa_task(): send NSSA aggregates"); |
| 1642 | /* ospf_abr_send_nssa_aggregates (); TURNED OFF FOR NOW */ |
| 1643 | |
| 1644 | /* Send any NSSA defaults as Type-5 */ |
| 1645 | if (IS_DEBUG_OSPF_NSSA) |
| 1646 | zlog_info ("ospf_abr_nssa_task(): announce nssa defaults"); |
| 1647 | ospf_abr_announce_nssa_defaults (); |
| 1648 | |
| 1649 | /* Flush any unapproved previous translates from Global Data Base */ |
| 1650 | if (IS_DEBUG_OSPF_NSSA) |
| 1651 | zlog_info ("ospf_abr_nssa_task(): remove unapproved translates"); |
| 1652 | ospf_abr_remove_unapproved_translates (); |
| 1653 | |
| 1654 | ospf_abr_manage_discard_routes (); /* same as normal...discard */ |
| 1655 | |
| 1656 | if (IS_DEBUG_OSPF_NSSA) |
| 1657 | zlog_info ("ospf_abr_nssa_task(): Stop"); |
| 1658 | } |
| 1659 | #endif /* HAVE_NSSA */ |
| 1660 | |
| 1661 | /* This is the function taking care about ABR stuff, i.e. |
| 1662 | summary-LSA origination and flooding. */ |
| 1663 | void |
| 1664 | ospf_abr_task () |
| 1665 | { |
| 1666 | if (IS_DEBUG_OSPF_EVENT) |
| 1667 | zlog_info ("ospf_abr_task(): Start"); |
| 1668 | |
| 1669 | if (ospf_top->new_table == NULL || ospf_top->new_rtrs == NULL) |
| 1670 | { |
| 1671 | if (IS_DEBUG_OSPF_EVENT) |
| 1672 | zlog_info ("ospf_abr_task(): Routing tables are not yet ready"); |
| 1673 | return; |
| 1674 | } |
| 1675 | |
| 1676 | if (IS_DEBUG_OSPF_EVENT) |
| 1677 | zlog_info ("ospf_abr_task(): unapprove summaries"); |
| 1678 | ospf_abr_unapprove_summaries (); |
| 1679 | |
| 1680 | if (IS_DEBUG_OSPF_EVENT) |
| 1681 | zlog_info ("ospf_abr_task(): prepare aggregates"); |
| 1682 | ospf_abr_prepare_aggregates (); |
| 1683 | |
| 1684 | if (OSPF_IS_ABR) |
| 1685 | { |
| 1686 | if (IS_DEBUG_OSPF_EVENT) |
| 1687 | zlog_info ("ospf_abr_task(): process network RT"); |
| 1688 | ospf_abr_process_network_rt (ospf_top->new_table); |
| 1689 | |
| 1690 | if (IS_DEBUG_OSPF_EVENT) |
| 1691 | zlog_info ("ospf_abr_task(): process router RT"); |
| 1692 | ospf_abr_process_router_rt (ospf_top->new_rtrs); |
| 1693 | |
| 1694 | if (IS_DEBUG_OSPF_EVENT) |
| 1695 | zlog_info ("ospf_abr_task(): announce aggregates"); |
| 1696 | ospf_abr_announce_aggregates (); |
| 1697 | |
| 1698 | if (IS_DEBUG_OSPF_EVENT) |
| 1699 | zlog_info ("ospf_abr_task(): announce stub defaults"); |
| 1700 | ospf_abr_announce_stub_defaults (); |
| 1701 | } |
| 1702 | |
| 1703 | if (IS_DEBUG_OSPF_EVENT) |
| 1704 | zlog_info ("ospf_abr_task(): remove unapproved summaries"); |
| 1705 | ospf_abr_remove_unapproved_summaries (); |
| 1706 | |
| 1707 | ospf_abr_manage_discard_routes (); |
| 1708 | |
| 1709 | #ifdef HAVE_NSSA |
| 1710 | ospf_abr_nssa_task(); /* if nssa-abr, then scan Type-7 LSDB */ |
| 1711 | #endif /* HAVE_NSSA */ |
| 1712 | |
| 1713 | if (IS_DEBUG_OSPF_EVENT) |
| 1714 | zlog_info ("ospf_abr_task(): Stop"); |
| 1715 | } |
| 1716 | |
| 1717 | |
| 1718 | int |
| 1719 | ospf_abr_task_timer (struct thread *t) |
| 1720 | { |
| 1721 | ospf_top->t_abr_task = 0; |
| 1722 | |
| 1723 | if (IS_DEBUG_OSPF_EVENT) |
| 1724 | zlog_info ("Running ABR task on timer"); |
| 1725 | |
| 1726 | ospf_check_abr_status (); |
| 1727 | |
| 1728 | ospf_abr_task (); |
| 1729 | |
| 1730 | return 0; |
| 1731 | } |
| 1732 | |
| 1733 | void |
| 1734 | ospf_schedule_abr_task () |
| 1735 | { |
| 1736 | if (IS_DEBUG_OSPF_EVENT) |
| 1737 | zlog_info ("Scheduling ABR task"); |
| 1738 | if (! ospf_top->t_abr_task) |
| 1739 | ospf_top->t_abr_task = thread_add_timer (master, ospf_abr_task_timer, |
| 1740 | 0, OSPF_ABR_TASK_DELAY); |
| 1741 | } |