blob: 8991bd71b95cf2e0e47637444bc8a991f7de480a [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * OSPF ABR functions.
3 * Copyright (C) 1999, 2000 Alex Zinin, Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23
24#include <zebra.h>
25
26#include "thread.h"
27#include "memory.h"
28#include "linklist.h"
29#include "prefix.h"
30#include "if.h"
31#include "table.h"
32#include "vty.h"
33#include "filter.h"
34#include "plist.h"
35#include "log.h"
36
37#include "ospfd/ospfd.h"
38#include "ospfd/ospf_interface.h"
39#include "ospfd/ospf_ism.h"
40#include "ospfd/ospf_asbr.h"
41#include "ospfd/ospf_lsa.h"
42#include "ospfd/ospf_lsdb.h"
43#include "ospfd/ospf_neighbor.h"
44#include "ospfd/ospf_nsm.h"
45#include "ospfd/ospf_spf.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_ia.h"
48#include "ospfd/ospf_flood.h"
49#include "ospfd/ospf_abr.h"
50#include "ospfd/ospf_ase.h"
51#include "ospfd/ospf_zebra.h"
52#include "ospfd/ospf_dump.h"
53
54
55struct ospf_area_range *
56ospf_area_range_new (struct prefix_ipv4 *p)
57{
58 struct ospf_area_range *range;
59
60 range = XCALLOC (MTYPE_OSPF_AREA_RANGE, sizeof (struct ospf_area_range));
61 range->addr = p->prefix;
62 range->masklen = p->prefixlen;
63 range->cost_config = OSPF_AREA_RANGE_COST_UNSPEC;
64
65 return range;
66}
67
68void
69ospf_area_range_free (struct ospf_area_range *range)
70{
71 XFREE (MTYPE_OSPF_AREA_RANGE, range);
72}
73
74void
75ospf_area_range_add (struct ospf_area *area, struct ospf_area_range *range)
76{
77 struct route_node *rn;
78 struct prefix_ipv4 p;
79
80 p.family = AF_INET;
81 p.prefixlen = range->masklen;
82 p.prefix = range->addr;
83
84 rn = route_node_get (area->ranges, (struct prefix *)&p);
85 if (rn->info)
86 route_unlock_node (rn);
87 else
88 rn->info = range;
89}
90
91void
92ospf_area_range_delete (struct ospf_area *area, struct ospf_area_range *range)
93{
94 struct route_node *rn;
95 struct prefix_ipv4 p;
96
97 p.family = AF_INET;
98 p.prefixlen = range->masklen;
99 p.prefix = range->addr;
100
101 rn = route_node_lookup (area->ranges, (struct prefix *)&p);
102 if (rn)
103 {
104 ospf_area_range_free (rn->info);
105 rn->info = NULL;
106 route_unlock_node (rn);
107 route_unlock_node (rn);
108 }
109}
110
111struct ospf_area_range *
112ospf_area_range_lookup (struct ospf_area *area, struct prefix_ipv4 *p)
113{
114 struct route_node *rn;
115
116 rn = route_node_lookup (area->ranges, (struct prefix *)p);
117 if (rn)
118 {
119 route_unlock_node (rn);
120 return rn->info;
121 }
122 return NULL;
123}
124
125struct ospf_area_range *
126ospf_area_range_lookup_next (struct ospf_area *area, struct in_addr *range_net,
127 int first)
128{
129 struct route_node *rn;
130 struct prefix_ipv4 p;
131 struct ospf_area_range *find;
132
133 p.family = AF_INET;
134 p.prefixlen = IPV4_MAX_BITLEN;
135 p.prefix = *range_net;
136
137 if (first)
138 rn = route_top (area->ranges);
139 else
140 {
141 rn = route_node_get (area->ranges, (struct prefix *) &p);
142 rn = route_next (rn);
143 }
144
145 for (; rn; rn = route_next (rn))
146 if (rn->info)
147 break;
148
149 if (rn && rn->info)
150 {
151 find = rn->info;
152 *range_net = rn->p.u.prefix4;
153 route_unlock_node (rn);
154 return find;
155 }
156 return NULL;
157}
158
159struct ospf_area_range *
160ospf_area_range_match (struct ospf_area *area, struct prefix_ipv4 *p)
161{
162 struct route_node *node;
163
164 node = route_node_match (area->ranges, (struct prefix *) p);
165 if (node)
166 {
167 route_unlock_node (node);
168 return node->info;
169 }
170 return NULL;
171}
172
173struct ospf_area_range *
174ospf_area_range_match_any (struct ospf *ospf, struct prefix_ipv4 *p)
175{
176 struct ospf_area_range *range;
177 listnode node;
178
179 for (node = listhead (ospf->areas); node; nextnode (node))
180 if ((range = ospf_area_range_match (node->data, p)))
181 return range;
182
183 return NULL;
184}
185
186int
187ospf_area_range_active (struct ospf_area_range *range)
188{
189 return range->specifics;
190}
191
192int
193ospf_area_actively_attached (struct ospf_area *area)
194{
195 return area->act_ints;
196}
197
198int
199ospf_area_range_set (struct ospf *ospf, struct in_addr area_id,
200 struct prefix_ipv4 *p, int advertise)
201{
202 struct ospf_area *area;
203 struct ospf_area_range *range;
paul147193a2003-04-19 00:31:59 +0000204 int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
paul718e3742002-12-13 20:15:29 +0000205
paul147193a2003-04-19 00:31:59 +0000206 area = ospf_area_get (ospf, area_id, ret);
paul718e3742002-12-13 20:15:29 +0000207 if (area == NULL)
208 return 0;
209
210 range = ospf_area_range_lookup (area, p);
211 if (range != NULL)
212 {
213 if ((CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)
214 && !CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))
215 || (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)
216 && CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE)))
paul147193a2003-04-19 00:31:59 +0000217 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000218 }
219 else
220 {
221 range = ospf_area_range_new (p);
222 ospf_area_range_add (area, range);
paul147193a2003-04-19 00:31:59 +0000223 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000224 }
225
226 if (CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))
227 SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
228 else
229 UNSET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
230
231 return 1;
232}
233
234int
235ospf_area_range_cost_set (struct ospf *ospf, struct in_addr area_id,
236 struct prefix_ipv4 *p, u_int32_t cost)
237{
238 struct ospf_area *area;
239 struct ospf_area_range *range;
paul147193a2003-04-19 00:31:59 +0000240 int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
paul718e3742002-12-13 20:15:29 +0000241
paul147193a2003-04-19 00:31:59 +0000242 area = ospf_area_get (ospf, area_id, ret);
paul718e3742002-12-13 20:15:29 +0000243 if (area == NULL)
244 return 0;
245
246 range = ospf_area_range_new (p);
247 if (range == NULL)
248 return 0;
249
250 if (range->cost_config != cost)
251 {
252 range->cost_config = cost;
253 if (ospf_area_range_active (range))
paul147193a2003-04-19 00:31:59 +0000254 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000255 }
256
257 return 1;
258}
259
260int
261ospf_area_range_unset (struct ospf *ospf, struct in_addr area_id,
262 struct prefix_ipv4 *p)
263{
264 struct ospf_area *area;
265 struct ospf_area_range *range;
266
paul147193a2003-04-19 00:31:59 +0000267 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +0000268 if (area == NULL)
269 return 0;
270
271 range = ospf_area_range_lookup (area, p);
272 if (range == NULL)
273 return 0;
274
275 if (ospf_area_range_active (range))
paul147193a2003-04-19 00:31:59 +0000276 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000277
278 ospf_area_range_delete (area, range);
279
280 return 1;
281}
282
283int
284ospf_area_range_substitute_set (struct ospf *ospf, struct in_addr area_id,
285 struct prefix_ipv4 *p, struct prefix_ipv4 *s)
286{
287 struct ospf_area *area;
288 struct ospf_area_range *range;
paul147193a2003-04-19 00:31:59 +0000289 int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
paul718e3742002-12-13 20:15:29 +0000290
paul147193a2003-04-19 00:31:59 +0000291 area = ospf_area_get (ospf, area_id, ret);
paul718e3742002-12-13 20:15:29 +0000292 range = ospf_area_range_lookup (area, p);
293
294 if (range != NULL)
295 {
296 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE) ||
297 !CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
paul147193a2003-04-19 00:31:59 +0000298 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000299 }
300 else
301 {
302 range = ospf_area_range_new (p);
303 ospf_area_range_add (area, range);
paul147193a2003-04-19 00:31:59 +0000304 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000305 }
306
307 SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
308 SET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE);
309 range->subst_addr = s->prefix;
310 range->subst_masklen = s->prefixlen;
311
312 return 1;
313}
314
315int
316ospf_area_range_substitute_unset (struct ospf *ospf, struct in_addr area_id,
317 struct prefix_ipv4 *p)
318{
319 struct ospf_area *area;
320 struct ospf_area_range *range;
321
paul147193a2003-04-19 00:31:59 +0000322 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +0000323 if (area == NULL)
324 return 0;
325
326 range = ospf_area_range_lookup (area, p);
327 if (range == NULL)
328 return 0;
329
330 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
331 if (ospf_area_range_active (range))
paul147193a2003-04-19 00:31:59 +0000332 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +0000333
334 UNSET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE);
335 range->subst_addr.s_addr = 0;
336 range->subst_masklen = 0;
337
338 return 1;
339}
340
341int
paul147193a2003-04-19 00:31:59 +0000342ospf_act_bb_connection (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +0000343{
paul147193a2003-04-19 00:31:59 +0000344 if (ospf->backbone == NULL)
paul718e3742002-12-13 20:15:29 +0000345 return 0;
346
paul147193a2003-04-19 00:31:59 +0000347 return ospf->backbone->full_nbrs;
paul718e3742002-12-13 20:15:29 +0000348}
349
paule2c6c152003-06-22 08:49:25 +0000350#ifdef HAVE_NSSA
351/* Determine whether this router is elected translator or not for area */
352int
353ospf_abr_nssa_am_elected (struct ospf_area *area)
354{
355 struct route_node *rn;
356 struct ospf_lsa *lsa;
357 struct router_lsa *rlsa;
358 struct in_addr *best = NULL;
359
360 LSDB_LOOP ( ROUTER_LSDB (area), rn, lsa)
361 {
362 /* sanity checks */
363 if (!lsa
364 || (lsa->data->type != OSPF_ROUTER_LSA)
365 || IS_LSA_SELF (lsa))
366 continue;
367
368 rlsa = (struct router_lsa *) lsa->data;
369
370 /* ignore non-ABR routers */
371 if (!IS_ROUTER_LSA_BORDER (rlsa))
372 continue;
373
374 /* Router has Nt flag - always translate */
375 if (IS_ROUTER_LSA_NT (rlsa))
376 {
377 if (IS_DEBUG_OSPF_NSSA)
378 zlog_info ("ospf_abr_nssa_am_elected: ",
379 "router %s asserts Nt",
380 inet_ntoa (lsa->data->id) );
381 return 0;
382 }
383
384 if (best == NULL)
385 best = &lsa->data->id;
386 else
387 if ( IPV4_ADDR_CMP (&best, &lsa->data->id) < 0)
388 best = &lsa->data->id;
389 }
390
391 if (IS_DEBUG_OSPF_NSSA)
392 zlog_info ("ospf_abr_nssa_am_elected: best electable ABR is: %s",
393 (best) ? inet_ntoa (*best) : "<none>" );
394
395 if (best == NULL)
396 return 1;
397
398 if ( IPV4_ADDR_CMP (&best, &area->ospf->router_id) < 0)
399 return 1;
400 else
401 return 0;
402}
403
404/* Check NSSA ABR status
405 * assumes there are nssa areas
406 */
407void
408ospf_abr_nssa_check_status (struct ospf *ospf)
409{
410 struct ospf_area *area;
411 listnode lnode;
412
413 LIST_LOOP (ospf->areas, area, lnode)
414 {
415
416 if (area->external_routing != OSPF_AREA_NSSA)
417 continue;
418
419 if (IS_DEBUG_OSPF (nssa, NSSA))
420 zlog_info ("ospf_abr_nssa_check_status: "
421 "checking area %s",
422 inet_ntoa (area->area_id));
423
424 if (!IS_OSPF_ABR (area->ospf))
425 {
426 if (IS_DEBUG_OSPF (nssa, NSSA))
427 zlog_info ("ospf_abr_nssa_check_status: "
428 "not ABR");
429 area->NSSATranslatorState = OSPF_NSSA_STATE_DISABLED;
430 continue;
431 }
432
433 switch (area->NSSATranslatorRole)
434 {
435 case OSPF_NSSA_ROLE_NEVER:
436 /* We never Translate Type-7 LSA. */
437 /* TODO: check previous state and flush? */
438 if (IS_DEBUG_OSPF (nssa, NSSA))
439 zlog_info ("ospf_abr_nssa_check_status: "
440 "never translate");
441 area->NSSATranslatorState = OSPF_NSSA_STATE_DISABLED;
442 continue;
443
444 case OSPF_NSSA_ROLE_ALWAYS:
445 /* We always translate if we are an ABR
446 * TODO: originate new LSAs if state change?
447 * or let the nssa abr task take care of it?
448 */
449 if (IS_DEBUG_OSPF (nssa, NSSA))
450 zlog_info ("ospf_abr_nssa_check_status: "
451 "translate always");
452 area->NSSATranslatorState = OSPF_NSSA_STATE_ENABLED;
453 continue;
454
455 case OSPF_NSSA_ROLE_CANDIDATE:
456 /* We are a candidate for Translation */
457 if (ospf_abr_nssa_am_elected (area) > 0 )
458 {
459 area->NSSATranslatorState = OSPF_NSSA_STATE_ENABLED;
460 if (IS_DEBUG_OSPF (nssa, NSSA))
461 zlog_info ("ospf_abr_nssa_check_status: "
462 "elected translator");
463 }
464 else
465 {
466 area->NSSATranslatorState = OSPF_NSSA_STATE_DISABLED;
467 if (IS_DEBUG_OSPF (nssa, NSSA))
468 zlog_info ("ospf_abr_nssa_check_status: "
469 "not elected");
470 }
471 continue;
472 }
473 }
474}
475#endif /* HAVE_NSSA */
476
paul718e3742002-12-13 20:15:29 +0000477/* Check area border router status. */
478void
paul147193a2003-04-19 00:31:59 +0000479ospf_check_abr_status (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +0000480{
481 struct ospf_area *area;
482 listnode node;
483 int bb_configured = 0;
484 int bb_act_attached = 0;
485 int areas_configured = 0;
486 int areas_act_attached = 0;
paul147193a2003-04-19 00:31:59 +0000487 u_char new_flags = ospf->flags;
paul718e3742002-12-13 20:15:29 +0000488
489 if (IS_DEBUG_OSPF_EVENT)
490 zlog_info ("ospf_check_abr_status(): Start");
491
paul147193a2003-04-19 00:31:59 +0000492 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +0000493 {
494 area = getdata (node);
paule2c6c152003-06-22 08:49:25 +0000495
paul718e3742002-12-13 20:15:29 +0000496 if (listcount (area->oiflist))
497 {
498 areas_configured++;
499
500 if (OSPF_IS_AREA_BACKBONE (area))
501 bb_configured = 1;
502 }
503
504 if (ospf_area_actively_attached (area))
505 {
506 areas_act_attached++;
507
508 if (OSPF_IS_AREA_BACKBONE (area))
509 bb_act_attached = 1;
510 }
511 }
512
513 if (IS_DEBUG_OSPF_EVENT)
514 {
515 zlog_info ("ospf_check_abr_status(): looked through areas");
516 zlog_info ("ospf_check_abr_status(): bb_configured: %d", bb_configured);
517 zlog_info ("ospf_check_abr_status(): bb_act_attached: %d",
518 bb_act_attached);
519 zlog_info ("ospf_check_abr_status(): areas_configured: %d",
520 areas_configured);
521 zlog_info ("ospf_check_abr_status(): areas_act_attached: %d",
522 areas_act_attached);
523 }
524
paul147193a2003-04-19 00:31:59 +0000525 switch (ospf->abr_type)
paul718e3742002-12-13 20:15:29 +0000526 {
527 case OSPF_ABR_SHORTCUT:
528 case OSPF_ABR_STAND:
529 if (areas_act_attached > 1)
530 SET_FLAG (new_flags, OSPF_FLAG_ABR);
531 else
532 UNSET_FLAG (new_flags, OSPF_FLAG_ABR);
533 break;
534
535 case OSPF_ABR_IBM:
536 if ((areas_act_attached > 1) && bb_configured)
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_CISCO:
543 if ((areas_configured > 1) && bb_act_attached)
544 SET_FLAG (new_flags, OSPF_FLAG_ABR);
545 else
546 UNSET_FLAG (new_flags, OSPF_FLAG_ABR);
547 break;
548 default:
549 break;
550 }
551
paul147193a2003-04-19 00:31:59 +0000552 if (new_flags != ospf->flags)
paul718e3742002-12-13 20:15:29 +0000553 {
paul147193a2003-04-19 00:31:59 +0000554 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000555 if (IS_DEBUG_OSPF_EVENT)
556 zlog_info ("ospf_check_abr_status(): new router flags: %x",new_flags);
paul147193a2003-04-19 00:31:59 +0000557 ospf->flags = new_flags;
558 OSPF_TIMER_ON (ospf->t_router_lsa_update,
paul718e3742002-12-13 20:15:29 +0000559 ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
560 }
561}
562
563void
564ospf_abr_update_aggregate (struct ospf_area_range *range,
565 struct ospf_route *or)
566{
567 if (IS_DEBUG_OSPF_EVENT)
568 zlog_info ("ospf_abr_update_aggregate(): Start");
569
570 if (range->cost_config != -1)
571 {
572 if (IS_DEBUG_OSPF_EVENT)
573 zlog_info ("ospf_abr_update_aggregate(): use configured cost %d",
574 range->cost_config);
575
576 range->cost = range->cost_config;
577 }
578 else
579 {
580 if (range->specifics == 0)
581 range->cost = or->cost; /* 1st time get 1st cost */
582
583 if (or->cost < range->cost)
584 {
585 if (IS_DEBUG_OSPF_EVENT)
586 zlog_info ("ospf_abr_update_aggregate(): lowest cost, update");
587
588 range->cost = or->cost;
589 }
590 }
591
592 range->specifics++;
593}
594
595static void
596set_metric (struct ospf_lsa *lsa, u_int32_t metric)
597{
598 struct summary_lsa *header;
599 u_char *mp;
600 metric = htonl (metric);
601 mp = (char *) &metric;
602 mp++;
603 header = (struct summary_lsa *) lsa->data;
604 memcpy(header->metric, mp, 3);
605}
606
607#ifdef HAVE_NSSA
608int
609ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost,
610 struct ospf_area *area)
611{
612 /* The Type-7 is tested against the aggregated prefix and forwarded
613 for lsa installation and flooding */
614 return 0;
615}
616
617/* ospf_abr_translate_nssa */
618int
paul147193a2003-04-19 00:31:59 +0000619ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000620{
621 /* Incoming Type-7 or later aggregated Type-7
622
623 LSA is skipped if P-bit is off.
624 LSA is aggregated if within range.
625
626 The Type-7 is translated, Installed/Approved as a Type-5 into
627 global LSDB, then Flooded through AS
628
629 Later, any Unapproved Translated Type-5's are flushed/discarded */
630
631 struct ospf_lsa *dup;
632
633 if (! CHECK_FLAG (lsa->data->options, OSPF_OPTION_NP))
634 {
635 if (IS_DEBUG_OSPF_NSSA)
636 zlog_info ("ospf_abr_nssa(): P-bit off, NO Translation");
637 return 0;
638 }
639
640 if (IS_DEBUG_OSPF_NSSA)
641 zlog_info ("ospf_abr_nssa(): TRANSLATING 7 to 5");
642
643 /* No more P-bit. */
644 /* UNSET_FLAG (lsa->data->options, OSPF_OPTION_NP); */
645
646 /* Area where Aggregate testing will be inserted, just like summary
647 advertisements */
648 /* ospf_abr_check_nssa_range (p_arg, lsa-> cost, lsa -> area); */
649
650 /* Follow thru here means no aggregation */
651 dup = ospf_lsa_dup (lsa); /* keep LSDB intact, lock = 1 */
652
653 SET_FLAG (dup->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7 */
654 SET_FLAG (dup->flags, OSPF_LSA_APPROVED); /* So, do not remove it */
655
656 dup->data->type = OSPF_AS_EXTERNAL_LSA; /* make Type-5 */
657
658 ospf_lsa_checksum (dup->data);
659
paul147193a2003-04-19 00:31:59 +0000660 ospf_lsa_install (area->ospf, NULL, dup); /* Install this Type-5 into LSDB, Lock = 2. */
paul718e3742002-12-13 20:15:29 +0000661
paul147193a2003-04-19 00:31:59 +0000662 ospf_flood_through_as (area->ospf, NULL, dup); /* flood non-NSSA/STUB areas */
paul718e3742002-12-13 20:15:29 +0000663
664 /* This translated Type-5 will go to all non-NSSA areas connected to
665 this ABR; The Type-5 could come from any of the NSSA's connected
666 to this ABR. */
667
668 return 0;
669}
670
671void
672ospf_abr_translate_nssa_range (struct prefix_ipv4 *p, u_int32_t cost)
673{
674 /* The Type-7 is created from the aggregated prefix and forwarded
675 for lsa installation and flooding... to be added... */
676}
677#endif /* HAVE_NSSA */
678
679void
680ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
681 struct ospf_area *area)
682{
683 struct ospf_lsa *lsa, *old = NULL;
684 struct summary_lsa *sl = NULL;
685
686 if (IS_DEBUG_OSPF_EVENT)
687 zlog_info ("ospf_abr_announce_network_to_area(): Start");
688
paul147193a2003-04-19 00:31:59 +0000689 old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA, p,
690 area->ospf->router_id);
paul718e3742002-12-13 20:15:29 +0000691 if (old)
692 {
693 if (IS_DEBUG_OSPF_EVENT)
694 zlog_info ("ospf_abr_announce_network_to_area(): old summary found");
695 sl = (struct summary_lsa *) old->data;
696
697 if (IS_DEBUG_OSPF_EVENT)
698 zlog_info ("ospf_abr_announce_network_to_area(): "
699 "old metric: %d, new metric: %d",
700 GET_METRIC (sl->metric), cost);
701 }
702
703 if (old && (GET_METRIC (sl->metric) == cost))
704 {
705 if (IS_DEBUG_OSPF_EVENT)
706 zlog_info ("ospf_abr_announce_network_to_area(): "
707 "old summary approved");
708 SET_FLAG (old->flags, OSPF_LSA_APPROVED);
709 }
710 else
711 {
712 if (IS_DEBUG_OSPF_EVENT)
713 zlog_info ("ospf_abr_announce_network_to_area(): "
714 "creating new summary");
715 if (old)
716 {
717
718 set_metric (old, cost);
paul147193a2003-04-19 00:31:59 +0000719 lsa = ospf_summary_lsa_refresh (area->ospf, old);
paul718e3742002-12-13 20:15:29 +0000720 /* This will flood through area. */
721 }
722 else
723 {
724 lsa = ospf_summary_lsa_originate (p, cost, area);
725 /* This will flood through area. */
726 }
727
728
729 SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
730 if (IS_DEBUG_OSPF_EVENT)
731 zlog_info ("ospf_abr_announce_network_to_area(): "
732 "flooding new version of summary");
733
paul718e3742002-12-13 20:15:29 +0000734 }
735
736 if (IS_DEBUG_OSPF_EVENT)
737 zlog_info ("ospf_abr_announce_network_to_area(): Stop");
738}
739
740int
741ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
742 struct ospf_area *area)
743{
744 listnode node;
745
746 for (node = listhead (or->path); node; nextnode (node))
747 {
748 struct ospf_path *path = node->data;
749 struct ospf_interface *oi = path->oi;
750
751 if (oi != NULL)
752 if (oi->area == area)
753 return 1;
754 }
755
756 return 0;
757}
758
759int
760ospf_abr_should_accept (struct prefix *p, struct ospf_area *area)
761{
762 if (IMPORT_NAME (area))
763 {
764 if (IMPORT_LIST (area) == NULL)
765 IMPORT_LIST (area) = access_list_lookup (AFI_IP, IMPORT_NAME (area));
766
767 if (IMPORT_LIST (area))
768 if (access_list_apply (IMPORT_LIST (area), p) == FILTER_DENY)
769 return 0;
770 }
771
772 return 1;
773}
774
775int
776ospf_abr_plist_in_check (struct ospf_area *area, struct ospf_route *or,
777 struct prefix *p)
778{
779 if (PREFIX_NAME_IN (area))
780 {
781 if (PREFIX_LIST_IN (area) == NULL)
782 PREFIX_LIST_IN (area) = prefix_list_lookup (AFI_IP,
783 PREFIX_NAME_IN (area));
784 if (PREFIX_LIST_IN (area))
785 if (prefix_list_apply (PREFIX_LIST_IN (area), p) != PREFIX_PERMIT)
786 return 0;
787 }
788 return 1;
789}
790
791int
792ospf_abr_plist_out_check (struct ospf_area *area, struct ospf_route *or,
793 struct prefix *p)
794{
795 if (PREFIX_NAME_OUT (area))
796 {
797 if (PREFIX_LIST_OUT (area) == NULL)
798 PREFIX_LIST_OUT (area) = prefix_list_lookup (AFI_IP,
799 PREFIX_NAME_OUT (area));
800 if (PREFIX_LIST_OUT (area))
801 if (prefix_list_apply (PREFIX_LIST_OUT (area), p) != PREFIX_PERMIT)
802 return 0;
803 }
804 return 1;
805}
806
807void
paul147193a2003-04-19 00:31:59 +0000808ospf_abr_announce_network (struct ospf *ospf,
809 struct route_node *n, struct ospf_route *or)
paul718e3742002-12-13 20:15:29 +0000810{
paul718e3742002-12-13 20:15:29 +0000811 struct ospf_area_range *range;
paul718e3742002-12-13 20:15:29 +0000812 struct ospf_area *area, *or_area;
paul147193a2003-04-19 00:31:59 +0000813 struct prefix_ipv4 *p;
814 listnode node;
paul718e3742002-12-13 20:15:29 +0000815
816 if (IS_DEBUG_OSPF_EVENT)
817 zlog_info ("ospf_abr_announce_network(): Start");
818 p = (struct prefix_ipv4 *) &n->p;
819
paul147193a2003-04-19 00:31:59 +0000820 or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
paul718e3742002-12-13 20:15:29 +0000821 assert (or_area);
822
paul147193a2003-04-19 00:31:59 +0000823 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +0000824 {
825 area = getdata (node);
826
827 if (IS_DEBUG_OSPF_EVENT)
828 zlog_info ("ospf_abr_announce_network(): looking at area %s",
829 inet_ntoa (area->area_id));
830
831 if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
832 continue;
833
834 if (ospf_abr_nexthops_belong_to_area (or, area))
835 continue;
836
837 if (!ospf_abr_should_accept (&n->p, area))
838 {
839 if (IS_DEBUG_OSPF_EVENT)
840 zlog_info ("ospf_abr_announce_network(): "
841 "prefix %s/%d was denied by import-list",
842 inet_ntoa (p->prefix), p->prefixlen);
843 continue;
844 }
845
846 if (!ospf_abr_plist_in_check (area, or, &n->p))
847 {
848 if (IS_DEBUG_OSPF_EVENT)
849 zlog_info ("ospf_abr_announce_network(): "
850 "prefix %s/%d was denied by prefix-list",
851 inet_ntoa (p->prefix), p->prefixlen);
852 continue;
853 }
854
855 if (area->external_routing != OSPF_AREA_DEFAULT && area->no_summary)
856 {
857 if (IS_DEBUG_OSPF_EVENT)
858 zlog_info ("ospf_abr_announce_network(): "
859 "area %s is stub and no_summary",
860 inet_ntoa (area->area_id));
861 continue;
862 }
863
864 if (or->path_type == OSPF_PATH_INTER_AREA)
865 {
866 if (IS_DEBUG_OSPF_EVENT)
867 zlog_info ("ospf_abr_announce_network(): this is "
868 "inter-area route to %s/%d",
869 inet_ntoa (p->prefix), p->prefixlen);
870
871 if (!OSPF_IS_AREA_BACKBONE (area))
872 ospf_abr_announce_network_to_area (p, or->cost, area);
873 }
874
875 if (or->path_type == OSPF_PATH_INTRA_AREA)
876 {
877 if (IS_DEBUG_OSPF_EVENT)
878 zlog_info ("ospf_abr_announce_network(): "
879 "this is intra-area route to %s/%d",
880 inet_ntoa (p->prefix), p->prefixlen);
881 if ((range = ospf_area_range_match (or_area, p)) &&
882 !ospf_area_is_transit (area))
883 ospf_abr_update_aggregate (range, or);
884 else
885 ospf_abr_announce_network_to_area (p, or->cost, area);
886 }
887 }
888}
889
890int
paul147193a2003-04-19 00:31:59 +0000891ospf_abr_should_announce (struct ospf *ospf,
892 struct prefix *p, struct ospf_route *or)
paul718e3742002-12-13 20:15:29 +0000893{
paul147193a2003-04-19 00:31:59 +0000894 struct ospf_area *area;
895
896 area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
paul718e3742002-12-13 20:15:29 +0000897
898 assert (area);
899
900 if (EXPORT_NAME (area))
901 {
902 if (EXPORT_LIST (area) == NULL)
903 EXPORT_LIST (area) = access_list_lookup (AFI_IP, EXPORT_NAME (area));
904
905 if (EXPORT_LIST (area))
906 if (access_list_apply (EXPORT_LIST (area), p) == FILTER_DENY)
907 return 0;
908 }
909
910 return 1;
911}
912
913#ifdef HAVE_NSSA
914void
paul147193a2003-04-19 00:31:59 +0000915ospf_abr_process_nssa_translates (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +0000916{
917 /* Scan through all NSSA_LSDB records for all areas;
918
919 If P-bit is on, translate all Type-7's to 5's and aggregate or
920 flood install as approved in Type-5 LSDB with XLATE Flag on
921 later, do same for all aggregates... At end, DISCARD all
922 remaining UNAPPROVED Type-5's (Aggregate is for future ) */
923 listnode node;
924 struct ospf_area *area;
paul147193a2003-04-19 00:31:59 +0000925 struct route_node *rn;
926 struct ospf_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000927
928 if (IS_DEBUG_OSPF_NSSA)
929 zlog_info ("ospf_abr_process_nssa_translates(): Start");
930
paul147193a2003-04-19 00:31:59 +0000931 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +0000932 {
933 area = getdata (node);
934
paule2c6c152003-06-22 08:49:25 +0000935 if (! area->NSSATranslatorState)
paul718e3742002-12-13 20:15:29 +0000936 continue; /* skip if not translator */
937
938 if (area->external_routing != OSPF_AREA_NSSA)
939 continue; /* skip if not Nssa Area */
940
941 if (IS_DEBUG_OSPF_NSSA)
942 zlog_info ("ospf_abr_process_nssa_translates(): "
943 "looking at area %s", inet_ntoa (area->area_id));
944
paul147193a2003-04-19 00:31:59 +0000945 LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
946 ospf_abr_translate_nssa (area, lsa);
paul718e3742002-12-13 20:15:29 +0000947 }
948
949 if (IS_DEBUG_OSPF_NSSA)
950 zlog_info ("ospf_abr_process_nssa_translates(): Stop");
951
952}
953#endif /* HAVE_NSSA */
954
955void
paul147193a2003-04-19 00:31:59 +0000956ospf_abr_process_network_rt (struct ospf *ospf,
957 struct route_table *rt)
paul718e3742002-12-13 20:15:29 +0000958{
paul718e3742002-12-13 20:15:29 +0000959 struct ospf_area *area;
paul147193a2003-04-19 00:31:59 +0000960 struct ospf_route *or;
961 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000962
963 if (IS_DEBUG_OSPF_EVENT)
964 zlog_info ("ospf_abr_process_network_rt(): Start");
965
966 for (rn = route_top (rt); rn; rn = route_next (rn))
967 {
968 if ((or = rn->info) == NULL)
969 continue;
970
paul147193a2003-04-19 00:31:59 +0000971 if (!(area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id)))
paul718e3742002-12-13 20:15:29 +0000972 {
973 if (IS_DEBUG_OSPF_EVENT)
974 zlog_info ("ospf_abr_process_network_rt(): area %s no longer exists",
975 inet_ntoa (or->u.std.area_id));
976 continue;
977 }
978
979 if (IS_DEBUG_OSPF_EVENT)
980 zlog_info ("ospf_abr_process_network_rt(): this is a route to %s/%d",
981 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
982 if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL)
983 {
984 if (IS_DEBUG_OSPF_EVENT)
985 zlog_info ("ospf_abr_process_network_rt(): "
986 "this is an External router, skipping");
987 continue;
988 }
989
990 if (or->cost >= OSPF_LS_INFINITY)
991 {
992 if (IS_DEBUG_OSPF_EVENT)
993 zlog_info ("ospf_abr_process_network_rt():"
994 " this route's cost is infinity, skipping");
995 continue;
996 }
997
998 if (or->type == OSPF_DESTINATION_DISCARD)
999 {
1000 if (IS_DEBUG_OSPF_EVENT)
1001 zlog_info ("ospf_abr_process_network_rt():"
1002 " this is a discard entry, skipping");
1003 continue;
1004 }
1005
1006 if (or->path_type == OSPF_PATH_INTRA_AREA &&
paul147193a2003-04-19 00:31:59 +00001007 !ospf_abr_should_announce (ospf, &rn->p, or))
paul718e3742002-12-13 20:15:29 +00001008 {
1009 if (IS_DEBUG_OSPF_EVENT)
1010 zlog_info("ospf_abr_process_network_rt(): denied by export-list");
1011 continue;
1012 }
1013
1014 if (or->path_type == OSPF_PATH_INTRA_AREA &&
1015 !ospf_abr_plist_out_check (area, or, &rn->p))
1016 {
1017 if (IS_DEBUG_OSPF_EVENT)
1018 zlog_info("ospf_abr_process_network_rt(): denied by prefix-list");
1019 continue;
1020 }
1021
1022 if ((or->path_type == OSPF_PATH_INTER_AREA) &&
1023 !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
1024 {
1025 if (IS_DEBUG_OSPF_EVENT)
1026 zlog_info ("ospf_abr_process_network_rt():"
1027 " this is route is not backbone one, skipping");
1028 continue;
1029 }
1030
1031
paul147193a2003-04-19 00:31:59 +00001032 if ((ospf->abr_type == OSPF_ABR_CISCO) ||
1033 (ospf->abr_type == OSPF_ABR_IBM))
paul718e3742002-12-13 20:15:29 +00001034
paul147193a2003-04-19 00:31:59 +00001035 if (!ospf_act_bb_connection (ospf) &&
paul718e3742002-12-13 20:15:29 +00001036 or->path_type != OSPF_PATH_INTRA_AREA)
1037 {
1038 if (IS_DEBUG_OSPF_EVENT)
1039 zlog_info ("ospf_abr_process_network_rt(): ALT ABR: "
1040 "No BB connection, skip not intra-area routes");
1041 continue;
1042 }
1043
1044 if (IS_DEBUG_OSPF_EVENT)
1045 zlog_info ("ospf_abr_process_network_rt(): announcing");
paul147193a2003-04-19 00:31:59 +00001046 ospf_abr_announce_network (ospf, rn, or);
paul718e3742002-12-13 20:15:29 +00001047 }
1048
1049 if (IS_DEBUG_OSPF_EVENT)
1050 zlog_info ("ospf_abr_process_network_rt(): Stop");
1051}
1052
1053void
1054ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
1055 struct ospf_area *area)
1056{
1057 struct ospf_lsa *lsa, *old = NULL;
1058 struct summary_lsa *slsa = NULL;
1059
1060 if (IS_DEBUG_OSPF_EVENT)
1061 zlog_info ("ospf_abr_announce_rtr_to_area(): Start");
1062
paul147193a2003-04-19 00:31:59 +00001063 old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_ASBR_SUMMARY_LSA,
1064 p, area->ospf->router_id);
paul718e3742002-12-13 20:15:29 +00001065 if (old)
1066 {
1067 if (IS_DEBUG_OSPF_EVENT)
1068 zlog_info ("ospf_abr_announce_rtr_to_area(): old summary found");
1069 slsa = (struct summary_lsa *) old->data;
1070
1071 if (IS_DEBUG_OSPF_EVENT)
1072 zlog_info ("ospf_abr_announce_network_to_area(): "
1073 "old metric: %d, new metric: %d",
1074 GET_METRIC (slsa->metric), cost);
1075 }
1076
1077 if (old && (GET_METRIC (slsa->metric) == cost))
1078 {
1079 if (IS_DEBUG_OSPF_EVENT)
1080 zlog_info ("ospf_abr_announce_rtr_to_area(): old summary approved");
1081 SET_FLAG (old->flags, OSPF_LSA_APPROVED);
1082 }
1083 else
1084 {
1085 if (IS_DEBUG_OSPF_EVENT)
1086 zlog_info ("ospf_abr_announce_rtr_to_area(): 2.2");
1087
1088 if (old)
1089 {
1090 set_metric (old, cost);
paul147193a2003-04-19 00:31:59 +00001091 lsa = ospf_summary_asbr_lsa_refresh (area->ospf, old);
paul718e3742002-12-13 20:15:29 +00001092 }
1093 else
1094 lsa = ospf_summary_asbr_lsa_originate (p, cost, area);
1095
1096 if (IS_DEBUG_OSPF_EVENT)
1097 zlog_info ("ospf_abr_announce_rtr_to_area(): "
1098 "flooding new version of summary");
1099 /*
1100 zlog_info ("ospf_abr_announce_rtr_to_area(): creating new summary");
1101 lsa = ospf_summary_asbr_lsa (p, cost, area, old); */
1102
1103 SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
1104 /* ospf_flood_through_area (area, NULL, lsa);*/
1105 }
1106
1107 if (IS_DEBUG_OSPF_EVENT)
1108 zlog_info ("ospf_abr_announce_rtr_to_area(): Stop");
1109}
1110
1111
1112void
paul147193a2003-04-19 00:31:59 +00001113ospf_abr_announce_rtr (struct ospf *ospf,
1114 struct prefix_ipv4 *p, struct ospf_route *or)
paul718e3742002-12-13 20:15:29 +00001115{
1116 listnode node;
1117 struct ospf_area *area;
1118
1119 if (IS_DEBUG_OSPF_EVENT)
1120 zlog_info ("ospf_abr_announce_rtr(): Start");
1121
paul147193a2003-04-19 00:31:59 +00001122 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001123 {
1124 area = getdata (node);
1125
1126 if (IS_DEBUG_OSPF_EVENT)
1127 zlog_info ("ospf_abr_announce_rtr(): looking at area %s",
1128 inet_ntoa (area->area_id));
1129
1130 if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
1131 continue;
1132
1133 if (ospf_abr_nexthops_belong_to_area (or, area))
1134 continue;
1135
1136 if (area->external_routing != OSPF_AREA_DEFAULT)
1137 {
1138 if (IS_DEBUG_OSPF_EVENT)
1139 zlog_info ("ospf_abr_announce_network(): "
1140 "area %s doesn't support external routing",
1141 inet_ntoa(area->area_id));
1142 continue;
1143 }
1144
1145 if (or->path_type == OSPF_PATH_INTER_AREA)
1146 {
1147 if (IS_DEBUG_OSPF_EVENT)
1148 zlog_info ("ospf_abr_announce_rtr(): "
1149 "this is inter-area route to %s", inet_ntoa (p->prefix));
1150 if (!OSPF_IS_AREA_BACKBONE (area))
1151 ospf_abr_announce_rtr_to_area (p, or->cost, area);
1152 }
1153
1154 if (or->path_type == OSPF_PATH_INTRA_AREA)
1155 {
1156 if (IS_DEBUG_OSPF_EVENT)
1157 zlog_info ("ospf_abr_announce_rtr(): "
1158 "this is intra-area route to %s", inet_ntoa (p->prefix));
1159 ospf_abr_announce_rtr_to_area (p, or->cost, area);
1160 }
1161 }
1162
1163 if (IS_DEBUG_OSPF_EVENT)
1164 zlog_info ("ospf_abr_announce_rtr(): Stop");
1165}
1166
1167void
paul147193a2003-04-19 00:31:59 +00001168ospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt)
paul718e3742002-12-13 20:15:29 +00001169{
paul718e3742002-12-13 20:15:29 +00001170 struct ospf_route *or;
paul147193a2003-04-19 00:31:59 +00001171 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00001172 struct list *l;
1173
1174 if (IS_DEBUG_OSPF_EVENT)
1175 zlog_info ("ospf_abr_process_router_rt(): Start");
1176
1177 for (rn = route_top (rt); rn; rn = route_next (rn))
1178 {
1179 listnode node;
1180 char flag = 0;
1181 struct ospf_route *best = NULL;
1182
1183 if (rn->info == NULL)
1184 continue;
1185
1186 l = rn->info;
1187
1188 if (IS_DEBUG_OSPF_EVENT)
1189 zlog_info ("ospf_abr_process_router_rt(): this is a route to %s",
1190 inet_ntoa (rn->p.u.prefix4));
1191
1192 for (node = listhead (l); node; nextnode (node))
1193 {
1194 or = getdata (node);
1195 if (or == NULL)
1196 continue;
1197
paul147193a2003-04-19 00:31:59 +00001198 if (!ospf_area_lookup_by_area_id (ospf, or->u.std.area_id))
paul718e3742002-12-13 20:15:29 +00001199 {
1200 if (IS_DEBUG_OSPF_EVENT)
1201 zlog_info ("ospf_abr_process_router_rt(): area %s no longer exists",
1202 inet_ntoa (or->u.std.area_id));
1203 continue;
1204 }
1205
1206
1207 if (!CHECK_FLAG (or->u.std.flags, ROUTER_LSA_EXTERNAL))
1208 {
1209 if (IS_DEBUG_OSPF_EVENT)
1210 zlog_info ("ospf_abr_process_router_rt(): "
1211 "This is not an ASBR, skipping");
1212 continue;
1213 }
1214
1215 if (!flag)
1216 {
paul147193a2003-04-19 00:31:59 +00001217 best = ospf_find_asbr_route (ospf, rt,
1218 (struct prefix_ipv4 *) &rn->p);
paul718e3742002-12-13 20:15:29 +00001219 flag = 1;
1220 }
1221
1222 if (best == NULL)
1223 continue;
1224
1225 if (or != best)
1226 {
1227 if (IS_DEBUG_OSPF_EVENT)
1228 zlog_info ("ospf_abr_process_router_rt(): "
1229 "This route is not the best among possible, skipping");
1230 continue;
1231 }
1232
1233 if (or->path_type == OSPF_PATH_INTER_AREA &&
1234 !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
1235 {
1236 if (IS_DEBUG_OSPF_EVENT)
1237 zlog_info ("ospf_abr_process_router_rt(): "
1238 "This route is not a backbone one, skipping");
1239 continue;
1240 }
1241
1242 if (or->cost >= OSPF_LS_INFINITY)
1243 {
1244 if (IS_DEBUG_OSPF_EVENT)
1245 zlog_info ("ospf_abr_process_router_rt(): "
1246 "This route has LS_INFINITY metric, skipping");
1247 continue;
1248 }
1249
paul147193a2003-04-19 00:31:59 +00001250 if (ospf->abr_type == OSPF_ABR_CISCO
1251 || ospf->abr_type == OSPF_ABR_IBM)
1252 if (!ospf_act_bb_connection (ospf)
1253 && or->path_type != OSPF_PATH_INTRA_AREA)
paul718e3742002-12-13 20:15:29 +00001254 {
1255 if (IS_DEBUG_OSPF_EVENT)
1256 zlog_info("ospf_abr_process_network_rt(): ALT ABR: "
1257 "No BB connection, skip not intra-area routes");
1258 continue;
1259 }
1260
paul147193a2003-04-19 00:31:59 +00001261 ospf_abr_announce_rtr (ospf, (struct prefix_ipv4 *) &rn->p, or);
paul718e3742002-12-13 20:15:29 +00001262
1263 }
1264
1265 }
1266
1267 if (IS_DEBUG_OSPF_EVENT)
1268 zlog_info ("ospf_abr_process_router_rt(): Stop");
1269}
1270
1271#ifdef HAVE_NSSA
paul718e3742002-12-13 20:15:29 +00001272void
paul147193a2003-04-19 00:31:59 +00001273ospf_abr_unapprove_translates (struct ospf *ospf) /* For NSSA Translations */
paul718e3742002-12-13 20:15:29 +00001274{
paul147193a2003-04-19 00:31:59 +00001275 struct ospf_lsa *lsa;
1276 struct route_node *rn;
1277
paul718e3742002-12-13 20:15:29 +00001278 if (IS_DEBUG_OSPF_NSSA)
1279 zlog_info ("ospf_abr_unapprove_translates(): Start");
1280
1281 /* NSSA Translator is not checked, because it may have gone away,
1282 and we would want to flush any residuals anyway */
1283
paul147193a2003-04-19 00:31:59 +00001284 LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
1285 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
1286 UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
paul718e3742002-12-13 20:15:29 +00001287
1288 if (IS_DEBUG_OSPF_NSSA)
1289 zlog_info ("ospf_abr_unapprove_translates(): Stop");
1290}
1291#endif /* HAVE_NSSA */
1292
paul718e3742002-12-13 20:15:29 +00001293void
paul147193a2003-04-19 00:31:59 +00001294ospf_abr_unapprove_summaries (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001295{
1296 listnode node;
1297 struct ospf_area *area;
paul147193a2003-04-19 00:31:59 +00001298 struct route_node *rn;
1299 struct ospf_lsa *lsa;
paul718e3742002-12-13 20:15:29 +00001300
1301 if (IS_DEBUG_OSPF_EVENT)
1302 zlog_info ("ospf_abr_unapprove_summaries(): Start");
1303
paul147193a2003-04-19 00:31:59 +00001304 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001305 {
1306 area = getdata (node);
paul147193a2003-04-19 00:31:59 +00001307 LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
1308 if (ospf_lsa_is_self_originated (ospf, lsa))
1309 UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
1310
1311 LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
1312 if (ospf_lsa_is_self_originated (ospf, lsa))
1313 UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
paul718e3742002-12-13 20:15:29 +00001314 }
1315
1316 if (IS_DEBUG_OSPF_EVENT)
1317 zlog_info ("ospf_abr_unapprove_summaries(): Stop");
1318}
1319
1320void
paul147193a2003-04-19 00:31:59 +00001321ospf_abr_prepare_aggregates (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001322{
1323 listnode node;
1324 struct route_node *rn;
1325 struct ospf_area_range *range;
1326
1327 if (IS_DEBUG_OSPF_EVENT)
1328 zlog_info ("ospf_abr_prepare_aggregates(): Start");
1329
paul147193a2003-04-19 00:31:59 +00001330 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001331 {
1332 struct ospf_area *area = getdata (node);
1333
1334 for (rn = route_top (area->ranges); rn; rn = route_next (rn))
1335 if ((range = rn->info) != NULL)
1336 {
1337 range->cost = 0;
1338 range->specifics = 0;
1339 }
1340 }
1341
1342 if (IS_DEBUG_OSPF_EVENT)
1343 zlog_info ("ospf_abr_prepare_aggregates(): Stop");
1344}
1345
1346void
paul147193a2003-04-19 00:31:59 +00001347ospf_abr_announce_aggregates (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001348{
1349 struct ospf_area *area, *ar;
1350 struct ospf_area_range *range;
1351 struct route_node *rn;
1352 struct prefix_ipv4 p;
1353 listnode node, n;
1354
1355 if (IS_DEBUG_OSPF_EVENT)
1356 zlog_info ("ospf_abr_announce_aggregates(): Start");
1357
paul147193a2003-04-19 00:31:59 +00001358 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001359 {
1360 area = getdata (node);
1361
1362 if (IS_DEBUG_OSPF_EVENT)
1363 zlog_info ("ospf_abr_announce_aggregates(): looking at area %s",
1364 inet_ntoa (area->area_id));
1365
1366 for (rn = route_top (area->ranges); rn; rn = route_next (rn))
1367 if ((range = rn->info))
1368 {
1369 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
1370 {
1371 if (IS_DEBUG_OSPF_EVENT)
1372 zlog_info ("ospf_abr_announce_aggregates():"
1373 " discarding suppress-ranges");
1374 continue;
1375 }
1376
1377 p.family = AF_INET;
1378 p.prefix = range->addr;
1379 p.prefixlen = range->masklen;
1380
1381 if (IS_DEBUG_OSPF_EVENT)
1382 zlog_info ("ospf_abr_announce_aggregates():"
1383 " this is range: %s/%d",
1384 inet_ntoa (p.prefix), p.prefixlen);
1385
1386 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
1387 {
1388 p.family = AF_INET;
1389 p.prefix = range->subst_addr;
1390 p.prefixlen = range->subst_masklen;
1391 }
1392
1393 if (range->specifics)
1394 {
1395 if (IS_DEBUG_OSPF_EVENT)
1396 zlog_info ("ospf_abr_announce_aggregates(): active range");
1397
paul147193a2003-04-19 00:31:59 +00001398 for (n = listhead (ospf->areas); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +00001399 {
1400 ar = getdata (n);
1401 if (ar == area)
1402 continue;
1403
1404 /* We do not check nexthops here, because
1405 intra-area routes can be associated with
1406 one area only */
1407
1408 /* backbone routes are not summarized
1409 when announced into transit areas */
1410
1411 if (ospf_area_is_transit (ar) &&
1412 OSPF_IS_AREA_BACKBONE (area))
1413 {
1414 if (IS_DEBUG_OSPF_EVENT)
1415 zlog_info ("ospf_abr_announce_aggregates(): Skipping "
1416 "announcement of BB aggregate into"
1417 " a transit area");
1418 continue;
1419 }
1420 ospf_abr_announce_network_to_area (&p, range->cost, ar);
1421 }
1422 }
1423 }
1424 }
1425
1426 if (IS_DEBUG_OSPF_EVENT)
1427 zlog_info ("ospf_abr_announce_aggregates(): Stop");
1428}
1429
1430#ifdef HAVE_NSSA
1431void
paul147193a2003-04-19 00:31:59 +00001432ospf_abr_send_nssa_aggregates (struct ospf *ospf) /* temporarily turned off */
paul718e3742002-12-13 20:15:29 +00001433{
1434 listnode node; /*, n; */
1435 struct ospf_area *area; /*, *ar; */
1436 struct route_node *rn;
1437 struct ospf_area_range *range;
1438 struct prefix_ipv4 p;
1439
1440 if (IS_DEBUG_OSPF_NSSA)
1441 zlog_info ("ospf_abr_send_nssa_aggregates(): Start");
1442
paul147193a2003-04-19 00:31:59 +00001443 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001444 {
1445 area = getdata (node);
1446
paule2c6c152003-06-22 08:49:25 +00001447 if (! area->NSSATranslatorState)
paul718e3742002-12-13 20:15:29 +00001448 continue;
1449
1450 if (IS_DEBUG_OSPF_NSSA)
1451 zlog_info ("ospf_abr_send_nssa_aggregates(): looking at area %s",
1452 inet_ntoa (area->area_id));
1453
1454 for (rn = route_top (area->ranges); rn; rn = route_next (rn))
1455 {
1456 if (rn->info == NULL)
1457 continue;
1458
1459 range = rn->info;
1460
1461 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
1462 {
1463 if (IS_DEBUG_OSPF_NSSA)
1464 zlog_info ("ospf_abr_send_nssa_aggregates():"
1465 " discarding suppress-ranges");
1466 continue;
1467 }
1468
1469 p.family = AF_INET;
1470 p.prefix = range->addr;
1471 p.prefixlen = range->masklen;
1472
1473 if (IS_DEBUG_OSPF_NSSA)
1474 zlog_info ("ospf_abr_send_nssa_aggregates():"
1475 " this is range: %s/%d",
1476 inet_ntoa (p.prefix), p.prefixlen);
1477
1478 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
1479 {
1480 p.family = AF_INET;
1481 p.prefix = range->subst_addr;
1482 p.prefixlen = range->subst_masklen;
1483 }
1484
1485 if (range->specifics)
paule2c6c152003-06-22 08:49:25 +00001486 {
1487 if (IS_DEBUG_OSPF_NSSA)
1488 zlog_info ("ospf_abr_send_nssa_aggregates(): active range");
paul718e3742002-12-13 20:15:29 +00001489
paule2c6c152003-06-22 08:49:25 +00001490 /* Fetch LSA-Type-7 from aggregate prefix, and then
1491 * translate, Install (as Type-5), Approve, and Flood
1492 */
1493 ospf_abr_translate_nssa_range (&p, range->cost);
1494 }
1495 } /* all area ranges*/
paul718e3742002-12-13 20:15:29 +00001496 } /* all areas */
1497
1498 if (IS_DEBUG_OSPF_NSSA)
1499 zlog_info ("ospf_abr_send_nssa_aggregates(): Stop");
1500}
1501
1502void
paul147193a2003-04-19 00:31:59 +00001503ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */
paul718e3742002-12-13 20:15:29 +00001504{
1505 listnode node;
1506 struct ospf_area *area;
1507 struct prefix_ipv4 p;
1508
paul147193a2003-04-19 00:31:59 +00001509 if (! IS_OSPF_ABR (ospf))
paul718e3742002-12-13 20:15:29 +00001510 return;
1511
1512 if (IS_DEBUG_OSPF_NSSA)
1513 zlog_info ("ospf_abr_announce_stub_defaults(): Start");
1514
1515 p.family = AF_INET;
1516 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1517 p.prefixlen = 0;
1518
paul147193a2003-04-19 00:31:59 +00001519 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001520 {
1521 area = getdata (node);
1522 if (IS_DEBUG_OSPF_NSSA)
paule2c6c152003-06-22 08:49:25 +00001523 zlog_info ("ospf_abr_announce_nssa_defaults(): looking at area %s",
1524 inet_ntoa (area->area_id));
paul718e3742002-12-13 20:15:29 +00001525
1526 if (area->external_routing != OSPF_AREA_NSSA)
paule2c6c152003-06-22 08:49:25 +00001527 continue;
paul718e3742002-12-13 20:15:29 +00001528
1529 if (OSPF_IS_AREA_BACKBONE (area))
paule2c6c152003-06-22 08:49:25 +00001530 continue; /* Sanity Check */
paul718e3742002-12-13 20:15:29 +00001531
1532 /* if (!TranslatorRole continue V 1.0 look for "always" conf */
paule2c6c152003-06-22 08:49:25 +00001533 if (area->NSSATranslatorState)
1534 {
1535 if (IS_DEBUG_OSPF_NSSA)
1536 zlog_info ("ospf_abr_announce_nssa_defaults(): "
1537 "announcing 0.0.0.0/0 to this nssa");
1538 /* ospf_abr_announce_nssa_asbr_to_as (&p, area->default_cost, area); */
1539 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1540 }
paul718e3742002-12-13 20:15:29 +00001541 }
1542}
1543#endif /* HAVE_NSSA */
1544
1545void
paul147193a2003-04-19 00:31:59 +00001546ospf_abr_announce_stub_defaults (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001547{
1548 listnode node;
1549 struct ospf_area *area;
1550 struct prefix_ipv4 p;
1551
paul147193a2003-04-19 00:31:59 +00001552 if (! IS_OSPF_ABR (ospf))
paul718e3742002-12-13 20:15:29 +00001553 return;
1554
1555 if (IS_DEBUG_OSPF_EVENT)
1556 zlog_info ("ospf_abr_announce_stub_defaults(): Start");
1557
1558 p.family = AF_INET;
1559 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1560 p.prefixlen = 0;
1561
paul147193a2003-04-19 00:31:59 +00001562 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001563 {
1564 area = getdata (node);
1565 if (IS_DEBUG_OSPF_EVENT)
1566 zlog_info ("ospf_abr_announce_stub_defaults(): looking at area %s",
1567 inet_ntoa (area->area_id));
1568
1569#ifdef HAVE_NSSA
1570 if (area->external_routing != OSPF_AREA_STUB)
1571#else /* ! HAVE_NSSA */
1572 if (area->external_routing == OSPF_AREA_DEFAULT)
1573#endif /* HAVE_NSSA */
1574 continue;
1575
1576 if (OSPF_IS_AREA_BACKBONE (area))
1577 continue; /* Sanity Check */
1578
1579 if (IS_DEBUG_OSPF_EVENT)
1580 zlog_info ("ospf_abr_announce_stub_defaults(): "
1581 "announcing 0.0.0.0/0 to this area");
1582 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1583 }
1584
1585 if (IS_DEBUG_OSPF_EVENT)
1586 zlog_info ("ospf_abr_announce_stub_defaults(): Stop");
1587}
1588
1589#ifdef HAVE_NSSA
1590int
paul147193a2003-04-19 00:31:59 +00001591ospf_abr_remove_unapproved_translates_apply (struct ospf *ospf,
1592 struct ospf_lsa *lsa)
paul718e3742002-12-13 20:15:29 +00001593{
1594 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)
1595 && ! CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
1596 {
1597 zlog_info ("ospf_abr_remove_unapproved_translates(): "
1598 "removing unapproved translates, ID: %s",
1599 inet_ntoa (lsa->data->id));
1600
1601 /* FLUSH THROUGHOUT AS */
paul147193a2003-04-19 00:31:59 +00001602 ospf_lsa_flush_as (ospf, lsa);
paul718e3742002-12-13 20:15:29 +00001603
1604 /* DISCARD from LSDB */
1605 }
1606 return 0;
1607}
1608
1609void
paul147193a2003-04-19 00:31:59 +00001610ospf_abr_remove_unapproved_translates (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001611{
paul147193a2003-04-19 00:31:59 +00001612 struct route_node *rn;
1613 struct ospf_lsa *lsa;
1614
paul718e3742002-12-13 20:15:29 +00001615 /* All AREA PROCESS should have APPROVED necessary LSAs */
1616 /* Remove any left over and not APPROVED */
1617 if (IS_DEBUG_OSPF_NSSA)
1618 zlog_info ("ospf_abr_remove_unapproved_translates(): Start");
1619
paul147193a2003-04-19 00:31:59 +00001620 LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
1621 ospf_abr_remove_unapproved_translates_apply (ospf, lsa);
paul718e3742002-12-13 20:15:29 +00001622
1623 if (IS_DEBUG_OSPF_NSSA)
1624 zlog_info ("ospf_abr_remove_unapproved_translates(): Stop");
1625}
1626#endif /* HAVE_NSSA */
1627
paul718e3742002-12-13 20:15:29 +00001628void
paul147193a2003-04-19 00:31:59 +00001629ospf_abr_remove_unapproved_summaries (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001630{
1631 listnode node;
1632 struct ospf_area *area;
paul147193a2003-04-19 00:31:59 +00001633 struct route_node *rn;
1634 struct ospf_lsa *lsa;
paul718e3742002-12-13 20:15:29 +00001635
1636 if (IS_DEBUG_OSPF_EVENT)
1637 zlog_info ("ospf_abr_remove_unapproved_summaries(): Start");
1638
paul147193a2003-04-19 00:31:59 +00001639 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001640 {
1641 area = getdata (node);
1642
1643 if (IS_DEBUG_OSPF_EVENT)
1644 zlog_info ("ospf_abr_remove_unapproved_summaries(): "
1645 "looking at area %s", inet_ntoa (area->area_id));
1646
paul147193a2003-04-19 00:31:59 +00001647 LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
1648 if (ospf_lsa_is_self_originated (ospf, lsa))
1649 if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
1650 ospf_lsa_flush_area (lsa, area);
1651
1652 LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
1653 if (ospf_lsa_is_self_originated (ospf, lsa))
1654 if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
1655 ospf_lsa_flush_area (lsa, area);
paul718e3742002-12-13 20:15:29 +00001656 }
1657
1658 if (IS_DEBUG_OSPF_EVENT)
1659 zlog_info ("ospf_abr_remove_unapproved_summaries(): Stop");
1660}
1661
1662void
paul147193a2003-04-19 00:31:59 +00001663ospf_abr_manage_discard_routes (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001664{
1665 listnode node;
1666 struct route_node *rn;
1667 struct ospf_area *area;
1668 struct ospf_area_range *range;
1669
paul147193a2003-04-19 00:31:59 +00001670 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001671 if ((area = node->data) != NULL)
1672 for (rn = route_top (area->ranges); rn; rn = route_next (rn))
1673 if ((range = rn->info) != NULL)
1674 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
1675 {
1676 if (range->specifics)
paul147193a2003-04-19 00:31:59 +00001677 ospf_add_discard_route (ospf->new_table, area,
paul718e3742002-12-13 20:15:29 +00001678 (struct prefix_ipv4 *) &rn->p);
1679 else
1680 ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
1681 }
1682}
1683
1684#ifdef HAVE_NSSA
1685/* This is the function taking care about ABR NSSA, i.e. NSSA
1686 Translator, -LSA aggregation and flooding. For all NSSAs
1687
1688 Any SELF-AS-LSA is in the Type-5 LSDB and Type-7 LSDB. These LSA's
1689 are refreshed from the Type-5 LSDB, installed into the Type-7 LSDB
1690 with the P-bit set.
1691
1692 Any received Type-5s are legal for an ABR, else illegal for IR.
1693 Received Type-7s are installed, by area, with incoming P-bit. They
1694 are flooded; if the Elected NSSA Translator, then P-bit off.
1695
1696 Additionally, this ABR will place "translated type-7's" into the
1697 Type-5 LSDB in order to keep track of APPROVAL or not.
1698
1699 It will scan through every area, looking for Type-7 LSAs with P-Bit
1700 SET. The Type-7's are either AS-FLOODED & 5-INSTALLED or
1701 AGGREGATED. Later, the AGGREGATED LSAs are AS-FLOODED &
1702 5-INSTALLED.
1703
1704 5-INSTALLED is into the Type-5 LSDB; Any UNAPPROVED Type-5 LSAs
1705 left over are FLUSHED and DISCARDED.
1706
1707 For External Calculations, any NSSA areas use the Type-7 AREA-LSDB,
1708 any ABR-non-NSSA areas use the Type-5 GLOBAL-LSDB. */
1709
1710void
paul147193a2003-04-19 00:31:59 +00001711ospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */
paul718e3742002-12-13 20:15:29 +00001712{
1713 if (IS_DEBUG_OSPF_NSSA)
1714 zlog_info ("Check for NSSA-ABR Tasks():");
1715
paul147193a2003-04-19 00:31:59 +00001716 if (! IS_OSPF_ABR (ospf))
paul718e3742002-12-13 20:15:29 +00001717 return;
1718
paul147193a2003-04-19 00:31:59 +00001719 if (! ospf->anyNSSA)
paul718e3742002-12-13 20:15:29 +00001720 return;
1721
1722 /* Each area must confirm TranslatorRole */
1723 if (IS_DEBUG_OSPF_NSSA)
1724 zlog_info ("ospf_abr_nssa_task(): Start");
1725
1726 /* For all Global Entries flagged "local-translate", unset APPROVED */
1727 if (IS_DEBUG_OSPF_NSSA)
1728 zlog_info ("ospf_abr_nssa_task(): unapprove translates");
1729
paul147193a2003-04-19 00:31:59 +00001730 ospf_abr_unapprove_translates (ospf);
paul718e3742002-12-13 20:15:29 +00001731
1732 /* RESET all Ranges in every Area, same as summaries */
1733 if (IS_DEBUG_OSPF_NSSA)
1734 zlog_info ("ospf_abr_nssa_task(): NSSA initialize aggregates");
paule2c6c152003-06-22 08:49:25 +00001735 ospf_abr_prepare_aggregates (ospf); /*TURNED OFF just for now */
paul718e3742002-12-13 20:15:29 +00001736
1737 /* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or
paule2c6c152003-06-22 08:49:25 +00001738 * Aggregate as Type-7
1739 * Install or Approve in Type-5 Global LSDB
1740 */
paul718e3742002-12-13 20:15:29 +00001741 if (IS_DEBUG_OSPF_NSSA)
1742 zlog_info ("ospf_abr_nssa_task(): process translates");
paul147193a2003-04-19 00:31:59 +00001743 ospf_abr_process_nssa_translates (ospf);
paul718e3742002-12-13 20:15:29 +00001744
1745 /* Translate/Send any "ranged" aggregates, and also 5-Install and
paule2c6c152003-06-22 08:49:25 +00001746 * Approve
1747 * Scan Type-7's for aggregates, translate to Type-5's,
1748 * Install/Flood/Approve
1749 */
paul718e3742002-12-13 20:15:29 +00001750 if (IS_DEBUG_OSPF_NSSA)
1751 zlog_info("ospf_abr_nssa_task(): send NSSA aggregates");
paule2c6c152003-06-22 08:49:25 +00001752 ospf_abr_send_nssa_aggregates (ospf); /*TURNED OFF FOR NOW */
paul718e3742002-12-13 20:15:29 +00001753
1754 /* Send any NSSA defaults as Type-5 */
1755 if (IS_DEBUG_OSPF_NSSA)
1756 zlog_info ("ospf_abr_nssa_task(): announce nssa defaults");
paul147193a2003-04-19 00:31:59 +00001757 ospf_abr_announce_nssa_defaults (ospf);
paul718e3742002-12-13 20:15:29 +00001758
1759 /* Flush any unapproved previous translates from Global Data Base */
1760 if (IS_DEBUG_OSPF_NSSA)
1761 zlog_info ("ospf_abr_nssa_task(): remove unapproved translates");
paul147193a2003-04-19 00:31:59 +00001762 ospf_abr_remove_unapproved_translates (ospf);
paul718e3742002-12-13 20:15:29 +00001763
paul147193a2003-04-19 00:31:59 +00001764 ospf_abr_manage_discard_routes (ospf); /* same as normal...discard */
paul718e3742002-12-13 20:15:29 +00001765
1766 if (IS_DEBUG_OSPF_NSSA)
1767 zlog_info ("ospf_abr_nssa_task(): Stop");
1768}
1769#endif /* HAVE_NSSA */
1770
1771/* This is the function taking care about ABR stuff, i.e.
1772 summary-LSA origination and flooding. */
1773void
paul147193a2003-04-19 00:31:59 +00001774ospf_abr_task (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001775{
1776 if (IS_DEBUG_OSPF_EVENT)
1777 zlog_info ("ospf_abr_task(): Start");
1778
paul147193a2003-04-19 00:31:59 +00001779 if (ospf->new_table == NULL || ospf->new_rtrs == NULL)
paul718e3742002-12-13 20:15:29 +00001780 {
1781 if (IS_DEBUG_OSPF_EVENT)
1782 zlog_info ("ospf_abr_task(): Routing tables are not yet ready");
1783 return;
1784 }
1785
1786 if (IS_DEBUG_OSPF_EVENT)
1787 zlog_info ("ospf_abr_task(): unapprove summaries");
paul147193a2003-04-19 00:31:59 +00001788 ospf_abr_unapprove_summaries (ospf);
paul718e3742002-12-13 20:15:29 +00001789
1790 if (IS_DEBUG_OSPF_EVENT)
1791 zlog_info ("ospf_abr_task(): prepare aggregates");
paul147193a2003-04-19 00:31:59 +00001792 ospf_abr_prepare_aggregates (ospf);
paul718e3742002-12-13 20:15:29 +00001793
paul147193a2003-04-19 00:31:59 +00001794 if (IS_OSPF_ABR (ospf))
paul718e3742002-12-13 20:15:29 +00001795 {
1796 if (IS_DEBUG_OSPF_EVENT)
1797 zlog_info ("ospf_abr_task(): process network RT");
paul147193a2003-04-19 00:31:59 +00001798 ospf_abr_process_network_rt (ospf, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00001799
1800 if (IS_DEBUG_OSPF_EVENT)
1801 zlog_info ("ospf_abr_task(): process router RT");
paul147193a2003-04-19 00:31:59 +00001802 ospf_abr_process_router_rt (ospf, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00001803
1804 if (IS_DEBUG_OSPF_EVENT)
1805 zlog_info ("ospf_abr_task(): announce aggregates");
paul147193a2003-04-19 00:31:59 +00001806 ospf_abr_announce_aggregates (ospf);
paul718e3742002-12-13 20:15:29 +00001807
1808 if (IS_DEBUG_OSPF_EVENT)
1809 zlog_info ("ospf_abr_task(): announce stub defaults");
paul147193a2003-04-19 00:31:59 +00001810 ospf_abr_announce_stub_defaults (ospf);
paul718e3742002-12-13 20:15:29 +00001811 }
1812
1813 if (IS_DEBUG_OSPF_EVENT)
1814 zlog_info ("ospf_abr_task(): remove unapproved summaries");
paul147193a2003-04-19 00:31:59 +00001815 ospf_abr_remove_unapproved_summaries (ospf);
paul718e3742002-12-13 20:15:29 +00001816
paul147193a2003-04-19 00:31:59 +00001817 ospf_abr_manage_discard_routes (ospf);
paul718e3742002-12-13 20:15:29 +00001818
paul718e3742002-12-13 20:15:29 +00001819 if (IS_DEBUG_OSPF_EVENT)
1820 zlog_info ("ospf_abr_task(): Stop");
1821}
1822
1823
1824int
paul147193a2003-04-19 00:31:59 +00001825ospf_abr_task_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +00001826{
paul147193a2003-04-19 00:31:59 +00001827 struct ospf *ospf = THREAD_ARG (thread);
1828
1829 ospf->t_abr_task = 0;
paul718e3742002-12-13 20:15:29 +00001830
1831 if (IS_DEBUG_OSPF_EVENT)
1832 zlog_info ("Running ABR task on timer");
1833
paul147193a2003-04-19 00:31:59 +00001834 ospf_check_abr_status (ospf);
paul718e3742002-12-13 20:15:29 +00001835
paul147193a2003-04-19 00:31:59 +00001836 ospf_abr_task (ospf);
paule2c6c152003-06-22 08:49:25 +00001837#ifdef HAVE_NSSA
1838 ospf_abr_nssa_check_status (ospf);
1839 ospf_abr_nssa_task (ospf); /* if nssa-abr, then scan Type-7 LSDB */
1840#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00001841
paul147193a2003-04-19 00:31:59 +00001842 return 0;
paul718e3742002-12-13 20:15:29 +00001843}
1844
1845void
paul147193a2003-04-19 00:31:59 +00001846ospf_schedule_abr_task (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001847{
1848 if (IS_DEBUG_OSPF_EVENT)
1849 zlog_info ("Scheduling ABR task");
paul147193a2003-04-19 00:31:59 +00001850
1851 if (ospf->t_abr_task == NULL)
1852 ospf->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,
1853 ospf, OSPF_ABR_TASK_DELAY);
paul718e3742002-12-13 20:15:29 +00001854}