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