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