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