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