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