3 * Copyright (C) 1999, 2000 Alex Zinin, Toshiaki Takada
5 * This file is part of GNU Zebra.
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
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.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
37 #include "ospfd/ospfd.h"
38 #include "ospfd/ospf_interface.h"
39 #include "ospfd/ospf_ism.h"
40 #include "ospfd/ospf_asbr.h"
41 #include "ospfd/ospf_lsa.h"
42 #include "ospfd/ospf_lsdb.h"
43 #include "ospfd/ospf_neighbor.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_spf.h"
46 #include "ospfd/ospf_route.h"
47 #include "ospfd/ospf_ia.h"
48 #include "ospfd/ospf_flood.h"
49 #include "ospfd/ospf_abr.h"
50 #include "ospfd/ospf_ase.h"
51 #include "ospfd/ospf_zebra.h"
52 #include "ospfd/ospf_dump.h"
54 struct ospf_area_range
*
55 ospf_area_range_new (struct prefix_ipv4
*p
)
57 struct ospf_area_range
*range
;
59 range
= XCALLOC (MTYPE_OSPF_AREA_RANGE
, sizeof (struct ospf_area_range
));
60 range
->addr
= p
->prefix
;
61 range
->masklen
= p
->prefixlen
;
62 range
->cost_config
= OSPF_AREA_RANGE_COST_UNSPEC
;
68 ospf_area_range_free (struct ospf_area_range
*range
)
70 XFREE (MTYPE_OSPF_AREA_RANGE
, range
);
74 ospf_area_range_add (struct ospf_area
*area
, struct ospf_area_range
*range
)
76 struct route_node
*rn
;
80 p
.prefixlen
= range
->masklen
;
81 p
.prefix
= range
->addr
;
83 rn
= route_node_get (area
->ranges
, (struct prefix
*)&p
);
85 route_unlock_node (rn
);
91 ospf_area_range_delete (struct ospf_area
*area
, struct ospf_area_range
*range
)
93 struct route_node
*rn
;
97 p
.prefixlen
= range
->masklen
;
98 p
.prefix
= range
->addr
;
100 rn
= route_node_lookup (area
->ranges
, (struct prefix
*)&p
);
103 ospf_area_range_free (rn
->info
);
105 route_unlock_node (rn
);
106 route_unlock_node (rn
);
110 struct ospf_area_range
*
111 ospf_area_range_lookup (struct ospf_area
*area
, struct prefix_ipv4
*p
)
113 struct route_node
*rn
;
115 rn
= route_node_lookup (area
->ranges
, (struct prefix
*)p
);
118 route_unlock_node (rn
);
124 struct ospf_area_range
*
125 ospf_area_range_lookup_next (struct ospf_area
*area
,
126 struct in_addr
*range_net
,
129 struct route_node
*rn
;
130 struct prefix_ipv4 p
;
131 struct ospf_area_range
*find
;
134 p
.prefixlen
= IPV4_MAX_BITLEN
;
135 p
.prefix
= *range_net
;
138 rn
= route_top (area
->ranges
);
141 rn
= route_node_get (area
->ranges
, (struct prefix
*) &p
);
142 rn
= route_next (rn
);
145 for (; rn
; rn
= route_next (rn
))
152 *range_net
= rn
->p
.u
.prefix4
;
153 route_unlock_node (rn
);
159 struct ospf_area_range
*
160 ospf_area_range_match (struct ospf_area
*area
, struct prefix_ipv4
*p
)
162 struct route_node
*node
;
164 node
= route_node_match (area
->ranges
, (struct prefix
*) p
);
167 route_unlock_node (node
);
173 struct ospf_area_range
*
174 ospf_area_range_match_any (struct ospf
*ospf
, struct prefix_ipv4
*p
)
176 struct ospf_area_range
*range
;
179 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
180 if ((range
= ospf_area_range_match (node
->data
, p
)))
187 ospf_area_range_active (struct ospf_area_range
*range
)
189 return range
->specifics
;
193 ospf_area_actively_attached (struct ospf_area
*area
)
195 return area
->act_ints
;
199 ospf_area_range_set (struct ospf
*ospf
, struct in_addr area_id
,
200 struct prefix_ipv4
*p
, int advertise
)
202 struct ospf_area
*area
;
203 struct ospf_area_range
*range
;
204 int ret
= OSPF_AREA_ID_FORMAT_ADDRESS
;
206 area
= ospf_area_get (ospf
, area_id
, ret
);
210 range
= ospf_area_range_lookup (area
, p
);
213 if ((CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
)
214 && !CHECK_FLAG (advertise
, OSPF_AREA_RANGE_ADVERTISE
))
215 || (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
)
216 && CHECK_FLAG (advertise
, OSPF_AREA_RANGE_ADVERTISE
)))
217 ospf_schedule_abr_task (ospf
);
221 range
= ospf_area_range_new (p
);
222 ospf_area_range_add (area
, range
);
223 ospf_schedule_abr_task (ospf
);
226 if (CHECK_FLAG (advertise
, OSPF_AREA_RANGE_ADVERTISE
))
227 SET_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
);
229 UNSET_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
);
235 ospf_area_range_cost_set (struct ospf
*ospf
, struct in_addr area_id
,
236 struct prefix_ipv4
*p
, u_int32_t cost
)
238 struct ospf_area
*area
;
239 struct ospf_area_range
*range
;
240 int ret
= OSPF_AREA_ID_FORMAT_ADDRESS
;
242 area
= ospf_area_get (ospf
, area_id
, ret
);
246 range
= ospf_area_range_new (p
);
250 if (range
->cost_config
!= cost
)
252 range
->cost_config
= cost
;
253 if (ospf_area_range_active (range
))
254 ospf_schedule_abr_task (ospf
);
261 ospf_area_range_unset (struct ospf
*ospf
, struct in_addr area_id
,
262 struct prefix_ipv4
*p
)
264 struct ospf_area
*area
;
265 struct ospf_area_range
*range
;
267 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
271 range
= ospf_area_range_lookup (area
, p
);
275 if (ospf_area_range_active (range
))
276 ospf_schedule_abr_task (ospf
);
278 ospf_area_range_delete (area
, range
);
284 ospf_area_range_substitute_set (struct ospf
*ospf
, struct in_addr area_id
,
285 struct prefix_ipv4
*p
, struct prefix_ipv4
*s
)
287 struct ospf_area
*area
;
288 struct ospf_area_range
*range
;
289 int ret
= OSPF_AREA_ID_FORMAT_ADDRESS
;
291 area
= ospf_area_get (ospf
, area_id
, ret
);
292 range
= ospf_area_range_lookup (area
, p
);
296 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
) ||
297 !CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
298 ospf_schedule_abr_task (ospf
);
302 range
= ospf_area_range_new (p
);
303 ospf_area_range_add (area
, range
);
304 ospf_schedule_abr_task (ospf
);
307 SET_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
);
308 SET_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
);
309 range
->subst_addr
= s
->prefix
;
310 range
->subst_masklen
= s
->prefixlen
;
316 ospf_area_range_substitute_unset (struct ospf
*ospf
, struct in_addr area_id
,
317 struct prefix_ipv4
*p
)
319 struct ospf_area
*area
;
320 struct ospf_area_range
*range
;
322 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
326 range
= ospf_area_range_lookup (area
, p
);
330 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
331 if (ospf_area_range_active (range
))
332 ospf_schedule_abr_task (ospf
);
334 UNSET_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
);
335 range
->subst_addr
.s_addr
= 0;
336 range
->subst_masklen
= 0;
342 ospf_act_bb_connection (struct ospf
*ospf
)
344 if (ospf
->backbone
== NULL
)
347 return ospf
->backbone
->full_nbrs
;
350 /* Determine whether this router is elected translator or not for area */
352 ospf_abr_nssa_am_elected (struct ospf_area
*area
)
354 struct route_node
*rn
;
355 struct ospf_lsa
*lsa
;
356 struct router_lsa
*rlsa
;
357 struct in_addr
*best
= NULL
;
359 LSDB_LOOP ( ROUTER_LSDB (area
), rn
, lsa
)
363 || (lsa
->data
->type
!= OSPF_ROUTER_LSA
)
364 || IS_LSA_SELF (lsa
))
367 rlsa
= (struct router_lsa
*) lsa
->data
;
369 /* ignore non-ABR routers */
370 if (!IS_ROUTER_LSA_BORDER (rlsa
))
373 /* Router has Nt flag - always translate */
374 if (IS_ROUTER_LSA_NT (rlsa
))
376 if (IS_DEBUG_OSPF_NSSA
)
377 zlog_info ("ospf_abr_nssa_am_elected: "
378 "router %s asserts Nt",
379 inet_ntoa (lsa
->data
->id
) );
384 best
= &lsa
->data
->id
;
386 if ( IPV4_ADDR_CMP (&best
, &lsa
->data
->id
) < 0)
387 best
= &lsa
->data
->id
;
390 if (IS_DEBUG_OSPF_NSSA
)
391 zlog_info ("ospf_abr_nssa_am_elected: best electable ABR is: %s",
392 (best
) ? inet_ntoa (*best
) : "<none>" );
397 if ( IPV4_ADDR_CMP (&best
, &area
->ospf
->router_id
) < 0)
403 /* Check NSSA ABR status
404 * assumes there are nssa areas
407 ospf_abr_nssa_check_status (struct ospf
*ospf
)
409 struct ospf_area
*area
;
412 LIST_LOOP (ospf
->areas
, area
, lnode
)
415 if (area
->external_routing
!= OSPF_AREA_NSSA
)
418 if (IS_DEBUG_OSPF (nssa
, NSSA
))
419 zlog_info ("ospf_abr_nssa_check_status: "
421 inet_ntoa (area
->area_id
));
423 if (!IS_OSPF_ABR (area
->ospf
))
425 if (IS_DEBUG_OSPF (nssa
, NSSA
))
426 zlog_info ("ospf_abr_nssa_check_status: "
428 area
->NSSATranslatorState
= OSPF_NSSA_TRANSLATE_DISABLED
;
432 switch (area
->NSSATranslatorRole
)
434 case OSPF_NSSA_ROLE_NEVER
:
435 /* We never Translate Type-7 LSA. */
436 /* TODO: check previous state and flush? */
437 if (IS_DEBUG_OSPF (nssa
, NSSA
))
438 zlog_info ("ospf_abr_nssa_check_status: "
440 area
->NSSATranslatorState
= OSPF_NSSA_TRANSLATE_DISABLED
;
443 case OSPF_NSSA_ROLE_ALWAYS
:
444 /* We always translate if we are an ABR
445 * TODO: originate new LSAs if state change?
446 * or let the nssa abr task take care of it?
448 if (IS_DEBUG_OSPF (nssa
, NSSA
))
449 zlog_info ("ospf_abr_nssa_check_status: "
451 area
->NSSATranslatorState
= OSPF_NSSA_TRANSLATE_ENABLED
;
454 case OSPF_NSSA_ROLE_CANDIDATE
:
455 /* We are a candidate for Translation */
456 if (ospf_abr_nssa_am_elected (area
) > 0 )
458 area
->NSSATranslatorState
= OSPF_NSSA_TRANSLATE_ENABLED
;
459 if (IS_DEBUG_OSPF (nssa
, NSSA
))
460 zlog_info ("ospf_abr_nssa_check_status: "
461 "elected translator");
465 area
->NSSATranslatorState
= OSPF_NSSA_TRANSLATE_DISABLED
;
466 if (IS_DEBUG_OSPF (nssa
, NSSA
))
467 zlog_info ("ospf_abr_nssa_check_status: "
475 /* Check area border router status. */
477 ospf_check_abr_status (struct ospf
*ospf
)
479 struct ospf_area
*area
;
481 int bb_configured
= 0;
482 int bb_act_attached
= 0;
483 int areas_configured
= 0;
484 int areas_act_attached
= 0;
485 u_char new_flags
= ospf
->flags
;
487 if (IS_DEBUG_OSPF_EVENT
)
488 zlog_info ("ospf_check_abr_status(): Start");
490 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
492 area
= getdata (node
);
494 if (listcount (area
->oiflist
))
498 if (OSPF_IS_AREA_BACKBONE (area
))
502 if (ospf_area_actively_attached (area
))
504 areas_act_attached
++;
506 if (OSPF_IS_AREA_BACKBONE (area
))
511 if (IS_DEBUG_OSPF_EVENT
)
513 zlog_info ("ospf_check_abr_status(): looked through areas");
514 zlog_info ("ospf_check_abr_status(): bb_configured: %d", bb_configured
);
515 zlog_info ("ospf_check_abr_status(): bb_act_attached: %d",
517 zlog_info ("ospf_check_abr_status(): areas_configured: %d",
519 zlog_info ("ospf_check_abr_status(): areas_act_attached: %d",
523 switch (ospf
->abr_type
)
525 case OSPF_ABR_SHORTCUT
:
527 if (areas_act_attached
> 1)
528 SET_FLAG (new_flags
, OSPF_FLAG_ABR
);
530 UNSET_FLAG (new_flags
, OSPF_FLAG_ABR
);
534 if ((areas_act_attached
> 1) && bb_configured
)
535 SET_FLAG (new_flags
, OSPF_FLAG_ABR
);
537 UNSET_FLAG (new_flags
, OSPF_FLAG_ABR
);
541 if ((areas_configured
> 1) && bb_act_attached
)
542 SET_FLAG (new_flags
, OSPF_FLAG_ABR
);
544 UNSET_FLAG (new_flags
, OSPF_FLAG_ABR
);
550 if (new_flags
!= ospf
->flags
)
552 ospf_spf_calculate_schedule (ospf
);
553 if (IS_DEBUG_OSPF_EVENT
)
554 zlog_info ("ospf_check_abr_status(): new router flags: %x",new_flags
);
555 ospf
->flags
= new_flags
;
556 OSPF_TIMER_ON (ospf
->t_router_lsa_update
,
557 ospf_router_lsa_update_timer
, OSPF_LSA_UPDATE_DELAY
);
562 ospf_abr_update_aggregate (struct ospf_area_range
*range
,
563 struct ospf_route
*or)
565 if (IS_DEBUG_OSPF_EVENT
)
566 zlog_info ("ospf_abr_update_aggregate(): Start");
568 if (range
->cost_config
!= -1)
570 if (IS_DEBUG_OSPF_EVENT
)
571 zlog_info ("ospf_abr_update_aggregate(): use configured cost %d",
574 range
->cost
= range
->cost_config
;
578 if (range
->specifics
== 0)
579 range
->cost
= or->cost
; /* 1st time get 1st cost */
581 if (or->cost
> range
->cost
)
583 if (IS_DEBUG_OSPF_EVENT
)
584 zlog_info ("ospf_abr_update_aggregate(): lowest cost, update");
586 range
->cost
= or->cost
;
594 set_metric (struct ospf_lsa
*lsa
, u_int32_t metric
)
596 struct summary_lsa
*header
;
598 metric
= htonl (metric
);
599 mp
= (char *) &metric
;
601 header
= (struct summary_lsa
*) lsa
->data
;
602 memcpy(header
->metric
, mp
, 3);
606 ospf_abr_check_nssa_range (struct prefix_ipv4
*p
, u_int32_t cost
,
607 struct ospf_area
*area
)
609 /* The Type-7 is tested against the aggregated prefix and forwarded
610 for lsa installation and flooding */
614 /* ospf_abr_translate_nssa */
616 ospf_abr_translate_nssa (struct ospf_area
*area
, struct ospf_lsa
*lsa
)
618 /* Incoming Type-7 or later aggregated Type-7
620 * LSA is skipped if P-bit is off.
621 * LSA is aggregated if within range.
623 * The Type-7 is translated, Installed/Approved as a Type-5 into
624 * global LSDB, then Flooded through AS
626 * Later, any Unapproved Translated Type-5's are flushed/discarded
629 struct ospf_lsa
*old
= NULL
,
631 struct as_external_lsa
*ext7
;
632 struct prefix_ipv4 p
;
634 if (! CHECK_FLAG (lsa
->data
->options
, OSPF_OPTION_NP
))
636 if (IS_DEBUG_OSPF_NSSA
)
637 zlog_info ("ospf_abr_translate_nssa(): LSA Id %s, P-bit off, NO Translation",
638 inet_ntoa (lsa
->data
->id
));
642 if (IS_DEBUG_OSPF_NSSA
)
643 zlog_info ("ospf_abr_translate_nssa(): LSA Id %s, TRANSLATING 7 to 5",
644 inet_ntoa (lsa
->data
->id
));
646 ext7
= (struct as_external_lsa
*)(lsa
->data
);
647 p
.prefix
= lsa
->data
->id
;
648 p
.prefixlen
= ip_masklen (ext7
->mask
);
650 if (ext7
->e
[0].fwd_addr
.s_addr
== OSPF_DEFAULT_DESTINATION
)
652 if (IS_DEBUG_OSPF_NSSA
)
653 zlog_info ("ospf_abr_translate_nssa(): LSA Id %s, "
654 "Forward address is 0, NO Translation",
655 inet_ntoa (lsa
->data
->id
));
659 /* try find existing AS-External LSA for this prefix */
661 old
= ospf_external_info_find_lsa (area
->ospf
, &p
);
665 if (IS_DEBUG_OSPF_NSSA
)
666 zlog_info ("ospf_abr_translate_nssa(): "
667 "found old translated LSA Id %s, refreshing",
668 inet_ntoa (old
->data
->id
));
671 new = ospf_translated_nssa_refresh (area
->ospf
, lsa
, old
);
674 if (IS_DEBUG_OSPF_NSSA
)
675 zlog_info ("ospf_abr_translate_nssa(): "
676 "could not refresh translated LSA Id %s",
677 inet_ntoa (old
->data
->id
));
682 /* no existing external route for this LSA Id
683 * originate translated LSA
686 if ((new = ospf_translated_nssa_originate (area
->ospf
, lsa
))
689 if (IS_DEBUG_OSPF_NSSA
)
690 zlog_info ("ospf_abr_translate_nssa(): Could not translate "
691 "Type-7 for %s to Type-5",
692 inet_ntoa (lsa
->data
->id
));
697 /* Area where Aggregate testing will be inserted, just like summary
699 /* ospf_abr_check_nssa_range (p_arg, lsa-> cost, lsa -> area); */
705 ospf_abr_translate_nssa_range (struct prefix_ipv4
*p
, u_int32_t cost
)
707 /* The Type-7 is created from the aggregated prefix and forwarded
708 for lsa installation and flooding... to be added... */
712 ospf_abr_announce_network_to_area (struct prefix_ipv4
*p
, u_int32_t cost
,
713 struct ospf_area
*area
)
715 struct ospf_lsa
*lsa
, *old
= NULL
;
716 struct summary_lsa
*sl
= NULL
;
718 if (IS_DEBUG_OSPF_EVENT
)
719 zlog_info ("ospf_abr_announce_network_to_area(): Start");
721 old
= ospf_lsa_lookup_by_prefix (area
->lsdb
, OSPF_SUMMARY_LSA
,
722 (struct prefix_ipv4
*) p
,
723 area
->ospf
->router_id
);
726 if (IS_DEBUG_OSPF_EVENT
)
727 zlog_info ("ospf_abr_announce_network_to_area(): old summary found");
729 sl
= (struct summary_lsa
*) old
->data
;
731 if (IS_DEBUG_OSPF_EVENT
)
732 zlog_info ("ospf_abr_announce_network_to_area(): "
733 "old metric: %d, new metric: %d",
734 GET_METRIC (sl
->metric
), cost
);
736 if (GET_METRIC (sl
->metric
) == cost
)
738 /* unchanged. simply reapprove it */
739 if (IS_DEBUG_OSPF_EVENT
)
740 zlog_info ("ospf_abr_announce_network_to_area(): "
741 "old summary approved");
742 SET_FLAG (old
->flags
, OSPF_LSA_APPROVED
);
746 /* LSA is changed, refresh it */
747 if (IS_DEBUG_OSPF_EVENT
)
748 zlog_info ("ospf_abr_announce_network_to_area(): "
749 "refreshing summary");
750 set_metric (old
, cost
);
751 lsa
= ospf_summary_lsa_refresh (area
->ospf
, old
);
752 /* This will flood through area. */
757 if (IS_DEBUG_OSPF_EVENT
)
758 zlog_info ("ospf_abr_announce_network_to_area(): "
759 "creating new summary");
760 lsa
= ospf_summary_lsa_originate ( (struct prefix_ipv4
*)p
, cost
, area
);
761 /* This will flood through area. */
763 SET_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
);
764 if (IS_DEBUG_OSPF_EVENT
)
765 zlog_info ("ospf_abr_announce_network_to_area(): "
766 "flooding new version of summary");
769 if (IS_DEBUG_OSPF_EVENT
)
770 zlog_info ("ospf_abr_announce_network_to_area(): Stop");
774 ospf_abr_nexthops_belong_to_area (struct ospf_route
*or,
775 struct ospf_area
*area
)
778 struct ospf_path
*path
;
780 LIST_LOOP (or->paths
, path
, node
)
782 struct ospf_interface
*oi
= path
->oi
;
785 if (oi
->area
== area
)
793 ospf_abr_should_accept (struct prefix_ipv4
*p
, struct ospf_area
*area
)
795 if (IMPORT_NAME (area
))
797 if (IMPORT_LIST (area
) == NULL
)
798 IMPORT_LIST (area
) = access_list_lookup (AFI_IP
, IMPORT_NAME (area
));
800 if (IMPORT_LIST (area
))
801 if (access_list_apply (IMPORT_LIST (area
), p
) == FILTER_DENY
)
809 ospf_abr_plist_in_check (struct ospf_area
*area
, struct ospf_route
*or,
810 struct prefix_ipv4
*p
)
812 if (PREFIX_NAME_IN (area
))
814 if (PREFIX_LIST_IN (area
) == NULL
)
815 PREFIX_LIST_IN (area
) = prefix_list_lookup (AFI_IP
,
816 PREFIX_NAME_IN (area
));
817 if (PREFIX_LIST_IN (area
))
818 if (prefix_list_apply (PREFIX_LIST_IN (area
), p
) != PREFIX_PERMIT
)
825 ospf_abr_plist_out_check (struct ospf_area
*area
, struct ospf_route
*or,
826 struct prefix_ipv4
*p
)
828 if (PREFIX_NAME_OUT (area
))
830 if (PREFIX_LIST_OUT (area
) == NULL
)
831 PREFIX_LIST_OUT (area
) = prefix_list_lookup (AFI_IP
,
832 PREFIX_NAME_OUT (area
));
833 if (PREFIX_LIST_OUT (area
))
834 if (prefix_list_apply (PREFIX_LIST_OUT (area
), p
) != PREFIX_PERMIT
)
841 ospf_abr_announce_network (struct ospf
*ospf
,
842 struct prefix_ipv4
*p
, struct ospf_route
*or)
844 struct ospf_area_range
*range
;
845 struct ospf_area
*area
, *or_area
;
848 if (IS_DEBUG_OSPF_EVENT
)
849 zlog_info ("ospf_abr_announce_network(): Start");
851 or_area
= ospf_area_lookup_by_area_id (ospf
, or->u
.std
.area_id
);
854 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
856 area
= getdata (node
);
858 if (IS_DEBUG_OSPF_EVENT
)
859 zlog_info ("ospf_abr_announce_network(): looking at area %s",
860 inet_ntoa (area
->area_id
));
862 if (IPV4_ADDR_SAME (&or->u
.std
.area_id
, &area
->area_id
))
865 if (ospf_abr_nexthops_belong_to_area (or, area
))
868 if (!ospf_abr_should_accept (p
, area
))
870 if (IS_DEBUG_OSPF_EVENT
)
871 zlog_info ("ospf_abr_announce_network(): "
872 "prefix %s/%d was denied by import-list",
873 inet_ntoa (p
->prefix
), p
->prefixlen
);
877 if (!ospf_abr_plist_in_check (area
, or, p
))
879 if (IS_DEBUG_OSPF_EVENT
)
880 zlog_info ("ospf_abr_announce_network(): "
881 "prefix %s/%d was denied by prefix-list",
882 inet_ntoa (p
->prefix
), p
->prefixlen
);
886 if (area
->external_routing
!= OSPF_AREA_DEFAULT
&& area
->no_summary
)
888 if (IS_DEBUG_OSPF_EVENT
)
889 zlog_info ("ospf_abr_announce_network(): "
890 "area %s is stub and no_summary",
891 inet_ntoa (area
->area_id
));
895 if (or->path_type
== OSPF_PATH_INTER_AREA
)
897 if (IS_DEBUG_OSPF_EVENT
)
898 zlog_info ("ospf_abr_announce_network(): this is "
899 "inter-area route to %s/%d",
900 inet_ntoa (p
->prefix
), p
->prefixlen
);
902 if (!OSPF_IS_AREA_BACKBONE (area
))
903 ospf_abr_announce_network_to_area (p
, or->cost
, area
);
906 if (or->path_type
== OSPF_PATH_INTRA_AREA
)
908 if (IS_DEBUG_OSPF_EVENT
)
909 zlog_info ("ospf_abr_announce_network(): "
910 "this is intra-area route to %s/%d",
911 inet_ntoa (p
->prefix
), p
->prefixlen
);
912 if ((range
= ospf_area_range_match (or_area
, p
))
913 && !ospf_area_is_transit (area
))
914 ospf_abr_update_aggregate (range
, or);
916 ospf_abr_announce_network_to_area (p
, or->cost
, area
);
922 ospf_abr_should_announce (struct ospf
*ospf
,
923 struct prefix_ipv4
*p
, struct ospf_route
*or)
925 struct ospf_area
*area
;
927 area
= ospf_area_lookup_by_area_id (ospf
, or->u
.std
.area_id
);
931 if (EXPORT_NAME (area
))
933 if (EXPORT_LIST (area
) == NULL
)
934 EXPORT_LIST (area
) = access_list_lookup (AFI_IP
, EXPORT_NAME (area
));
936 if (EXPORT_LIST (area
))
937 if (access_list_apply (EXPORT_LIST (area
), p
) == FILTER_DENY
)
945 ospf_abr_process_nssa_translates (struct ospf
*ospf
)
947 /* Scan through all NSSA_LSDB records for all areas;
949 If P-bit is on, translate all Type-7's to 5's and aggregate or
950 flood install as approved in Type-5 LSDB with XLATE Flag on
951 later, do same for all aggregates... At end, DISCARD all
952 remaining UNAPPROVED Type-5's (Aggregate is for future ) */
954 struct ospf_area
*area
;
955 struct route_node
*rn
;
956 struct ospf_lsa
*lsa
;
958 if (IS_DEBUG_OSPF_NSSA
)
959 zlog_info ("ospf_abr_process_nssa_translates(): Start");
961 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
963 area
= getdata (node
);
965 if (! area
->NSSATranslatorState
)
966 continue; /* skip if not translator */
968 if (area
->external_routing
!= OSPF_AREA_NSSA
)
969 continue; /* skip if not Nssa Area */
971 if (IS_DEBUG_OSPF_NSSA
)
972 zlog_info ("ospf_abr_process_nssa_translates(): "
973 "looking at area %s", inet_ntoa (area
->area_id
));
975 LSDB_LOOP (NSSA_LSDB (area
), rn
, lsa
)
976 ospf_abr_translate_nssa (area
, lsa
);
979 if (IS_DEBUG_OSPF_NSSA
)
980 zlog_info ("ospf_abr_process_nssa_translates(): Stop");
985 ospf_abr_process_network_rt (struct ospf
*ospf
,
986 struct route_table
*rt
)
988 struct ospf_area
*area
;
989 struct ospf_route
*or;
990 struct route_node
*rn
;
992 if (IS_DEBUG_OSPF_EVENT
)
993 zlog_info ("ospf_abr_process_network_rt(): Start");
995 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
997 if ((or = rn
->info
) == NULL
)
1000 if (!(area
= ospf_area_lookup_by_area_id (ospf
, or->u
.std
.area_id
)))
1002 if (IS_DEBUG_OSPF_EVENT
)
1003 zlog_info ("ospf_abr_process_network_rt(): area %s no longer exists",
1004 inet_ntoa (or->u
.std
.area_id
));
1008 if (IS_DEBUG_OSPF_EVENT
)
1009 zlog_info ("ospf_abr_process_network_rt(): this is a route to %s/%d",
1010 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
1011 if (or->path_type
>= OSPF_PATH_TYPE1_EXTERNAL
)
1013 if (IS_DEBUG_OSPF_EVENT
)
1014 zlog_info ("ospf_abr_process_network_rt(): "
1015 "this is an External router, skipping");
1019 if (or->cost
>= OSPF_LS_INFINITY
)
1021 if (IS_DEBUG_OSPF_EVENT
)
1022 zlog_info ("ospf_abr_process_network_rt():"
1023 " this route's cost is infinity, skipping");
1027 if (or->type
== OSPF_DESTINATION_DISCARD
)
1029 if (IS_DEBUG_OSPF_EVENT
)
1030 zlog_info ("ospf_abr_process_network_rt():"
1031 " this is a discard entry, skipping");
1035 if (or->path_type
== OSPF_PATH_INTRA_AREA
&&
1036 !ospf_abr_should_announce (ospf
, (struct prefix_ipv4
*) &rn
->p
, or))
1038 if (IS_DEBUG_OSPF_EVENT
)
1039 zlog_info("ospf_abr_process_network_rt(): denied by export-list");
1043 if (or->path_type
== OSPF_PATH_INTRA_AREA
&&
1044 !ospf_abr_plist_out_check (area
, or, (struct prefix_ipv4
*) &rn
->p
))
1046 if (IS_DEBUG_OSPF_EVENT
)
1047 zlog_info("ospf_abr_process_network_rt(): denied by prefix-list");
1051 if ((or->path_type
== OSPF_PATH_INTER_AREA
) &&
1052 !OSPF_IS_AREA_ID_BACKBONE (or->u
.std
.area_id
))
1054 if (IS_DEBUG_OSPF_EVENT
)
1055 zlog_info ("ospf_abr_process_network_rt():"
1056 " this is route is not backbone one, skipping");
1061 if ((ospf
->abr_type
== OSPF_ABR_CISCO
) ||
1062 (ospf
->abr_type
== OSPF_ABR_IBM
))
1064 if (!ospf_act_bb_connection (ospf
) &&
1065 or->path_type
!= OSPF_PATH_INTRA_AREA
)
1067 if (IS_DEBUG_OSPF_EVENT
)
1068 zlog_info ("ospf_abr_process_network_rt(): ALT ABR: "
1069 "No BB connection, skip not intra-area routes");
1073 if (IS_DEBUG_OSPF_EVENT
)
1074 zlog_info ("ospf_abr_process_network_rt(): announcing");
1075 ospf_abr_announce_network (ospf
, (struct prefix_ipv4
*)&rn
->p
, or);
1078 if (IS_DEBUG_OSPF_EVENT
)
1079 zlog_info ("ospf_abr_process_network_rt(): Stop");
1083 ospf_abr_announce_rtr_to_area (struct prefix_ipv4
*p
, u_int32_t cost
,
1084 struct ospf_area
*area
)
1086 struct ospf_lsa
*lsa
, *old
= NULL
;
1087 struct summary_lsa
*slsa
= NULL
;
1089 if (IS_DEBUG_OSPF_EVENT
)
1090 zlog_info ("ospf_abr_announce_rtr_to_area(): Start");
1092 old
= ospf_lsa_lookup_by_prefix (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
,
1093 p
, area
->ospf
->router_id
);
1096 if (IS_DEBUG_OSPF_EVENT
)
1097 zlog_info ("ospf_abr_announce_rtr_to_area(): old summary found");
1098 slsa
= (struct summary_lsa
*) old
->data
;
1100 if (IS_DEBUG_OSPF_EVENT
)
1101 zlog_info ("ospf_abr_announce_network_to_area(): "
1102 "old metric: %d, new metric: %d",
1103 GET_METRIC (slsa
->metric
), cost
);
1106 if (old
&& (GET_METRIC (slsa
->metric
) == cost
))
1108 if (IS_DEBUG_OSPF_EVENT
)
1109 zlog_info ("ospf_abr_announce_rtr_to_area(): old summary approved");
1110 SET_FLAG (old
->flags
, OSPF_LSA_APPROVED
);
1114 if (IS_DEBUG_OSPF_EVENT
)
1115 zlog_info ("ospf_abr_announce_rtr_to_area(): 2.2");
1119 set_metric (old
, cost
);
1120 lsa
= ospf_summary_asbr_lsa_refresh (area
->ospf
, old
);
1123 lsa
= ospf_summary_asbr_lsa_originate (p
, cost
, area
);
1125 if (IS_DEBUG_OSPF_EVENT
)
1126 zlog_info ("ospf_abr_announce_rtr_to_area(): "
1127 "flooding new version of summary");
1129 zlog_info ("ospf_abr_announce_rtr_to_area(): creating new summary");
1130 lsa = ospf_summary_asbr_lsa (p, cost, area, old); */
1132 SET_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
);
1133 /* ospf_flood_through_area (area, NULL, lsa);*/
1136 if (IS_DEBUG_OSPF_EVENT
)
1137 zlog_info ("ospf_abr_announce_rtr_to_area(): Stop");
1142 ospf_abr_announce_rtr (struct ospf
*ospf
,
1143 struct prefix_ipv4
*p
, struct ospf_route
*or)
1146 struct ospf_area
*area
;
1148 if (IS_DEBUG_OSPF_EVENT
)
1149 zlog_info ("ospf_abr_announce_rtr(): Start");
1151 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1153 area
= getdata (node
);
1155 if (IS_DEBUG_OSPF_EVENT
)
1156 zlog_info ("ospf_abr_announce_rtr(): looking at area %s",
1157 inet_ntoa (area
->area_id
));
1159 if (IPV4_ADDR_SAME (&or->u
.std
.area_id
, &area
->area_id
))
1162 if (ospf_abr_nexthops_belong_to_area (or, area
))
1165 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
1167 if (IS_DEBUG_OSPF_EVENT
)
1168 zlog_info ("ospf_abr_announce_rtr(): "
1169 "area %s doesn't support external routing",
1170 inet_ntoa(area
->area_id
));
1174 if (or->path_type
== OSPF_PATH_INTER_AREA
)
1176 if (IS_DEBUG_OSPF_EVENT
)
1177 zlog_info ("ospf_abr_announce_rtr(): "
1178 "this is inter-area route to %s", inet_ntoa (p
->prefix
));
1179 if (!OSPF_IS_AREA_BACKBONE (area
))
1180 ospf_abr_announce_rtr_to_area (p
, or->cost
, area
);
1183 if (or->path_type
== OSPF_PATH_INTRA_AREA
)
1185 if (IS_DEBUG_OSPF_EVENT
)
1186 zlog_info ("ospf_abr_announce_rtr(): "
1187 "this is intra-area route to %s", inet_ntoa (p
->prefix
));
1188 ospf_abr_announce_rtr_to_area (p
, or->cost
, area
);
1192 if (IS_DEBUG_OSPF_EVENT
)
1193 zlog_info ("ospf_abr_announce_rtr(): Stop");
1197 ospf_abr_process_router_rt (struct ospf
*ospf
, struct route_table
*rt
)
1199 struct ospf_route
*or;
1200 struct route_node
*rn
;
1203 if (IS_DEBUG_OSPF_EVENT
)
1204 zlog_info ("ospf_abr_process_router_rt(): Start");
1206 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
1210 struct ospf_route
*best
= NULL
;
1212 if (rn
->info
== NULL
)
1217 if (IS_DEBUG_OSPF_EVENT
)
1218 zlog_info ("ospf_abr_process_router_rt(): this is a route to %s",
1219 inet_ntoa (rn
->p
.u
.prefix4
));
1221 for (node
= listhead (l
); node
; nextnode (node
))
1223 or = getdata (node
);
1227 if (!ospf_area_lookup_by_area_id (ospf
, or->u
.std
.area_id
))
1229 if (IS_DEBUG_OSPF_EVENT
)
1230 zlog_info ("ospf_abr_process_router_rt(): area %s no longer exists",
1231 inet_ntoa (or->u
.std
.area_id
));
1236 if (!CHECK_FLAG (or->u
.std
.flags
, ROUTER_LSA_EXTERNAL
))
1238 if (IS_DEBUG_OSPF_EVENT
)
1239 zlog_info ("ospf_abr_process_router_rt(): "
1240 "This is not an ASBR, skipping");
1246 best
= ospf_find_asbr_route (ospf
, rt
,
1247 (struct prefix_ipv4
*) &rn
->p
);
1256 if (IS_DEBUG_OSPF_EVENT
)
1257 zlog_info ("ospf_abr_process_router_rt(): "
1258 "This route is not the best among possible, skipping");
1262 if (or->path_type
== OSPF_PATH_INTER_AREA
&&
1263 !OSPF_IS_AREA_ID_BACKBONE (or->u
.std
.area_id
))
1265 if (IS_DEBUG_OSPF_EVENT
)
1266 zlog_info ("ospf_abr_process_router_rt(): "
1267 "This route is not a backbone one, skipping");
1271 if (or->cost
>= OSPF_LS_INFINITY
)
1273 if (IS_DEBUG_OSPF_EVENT
)
1274 zlog_info ("ospf_abr_process_router_rt(): "
1275 "This route has LS_INFINITY metric, skipping");
1279 if (ospf
->abr_type
== OSPF_ABR_CISCO
1280 || ospf
->abr_type
== OSPF_ABR_IBM
)
1281 if (!ospf_act_bb_connection (ospf
)
1282 && or->path_type
!= OSPF_PATH_INTRA_AREA
)
1284 if (IS_DEBUG_OSPF_EVENT
)
1285 zlog_info("ospf_abr_process_network_rt(): ALT ABR: "
1286 "No BB connection, skip not intra-area routes");
1290 ospf_abr_announce_rtr (ospf
, (struct prefix_ipv4
*) &rn
->p
, or);
1296 if (IS_DEBUG_OSPF_EVENT
)
1297 zlog_info ("ospf_abr_process_router_rt(): Stop");
1301 ospf_abr_unapprove_translates (struct ospf
*ospf
) /* For NSSA Translations */
1303 struct ospf_lsa
*lsa
;
1304 struct route_node
*rn
;
1306 if (IS_DEBUG_OSPF_NSSA
)
1307 zlog_info ("ospf_abr_unapprove_translates(): Start");
1309 /* NSSA Translator is not checked, because it may have gone away,
1310 and we would want to flush any residuals anyway */
1312 LSDB_LOOP (EXTERNAL_LSDB (ospf
), rn
, lsa
)
1313 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
1315 UNSET_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
);
1316 if (IS_DEBUG_OSPF_NSSA
)
1317 zlog_info ("ospf_abr_unapprove_translates(): "
1318 "approved unset on link id %s",
1319 inet_ntoa (lsa
->data
->id
));
1322 if (IS_DEBUG_OSPF_NSSA
)
1323 zlog_info ("ospf_abr_unapprove_translates(): Stop");
1327 ospf_abr_unapprove_summaries (struct ospf
*ospf
)
1330 struct ospf_area
*area
;
1331 struct route_node
*rn
;
1332 struct ospf_lsa
*lsa
;
1334 if (IS_DEBUG_OSPF_EVENT
)
1335 zlog_info ("ospf_abr_unapprove_summaries(): Start");
1337 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1339 area
= getdata (node
);
1340 if (IS_DEBUG_OSPF_EVENT
)
1341 zlog_info ("ospf_abr_unapprove_summaries(): "
1342 "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
))
1347 if (IS_DEBUG_OSPF_EVENT
)
1348 zlog_info ("ospf_abr_unapprove_summaries(): "
1349 "approved unset on summary link id %s",
1350 inet_ntoa (lsa
->data
->id
));
1351 UNSET_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
);
1354 LSDB_LOOP (ASBR_SUMMARY_LSDB (area
), rn
, lsa
)
1355 if (ospf_lsa_is_self_originated (ospf
, lsa
))
1357 if (IS_DEBUG_OSPF_EVENT
)
1358 zlog_info ("ospf_abr_unapprove_summaries(): "
1359 "approved unset on asbr-summary link id %s",
1360 inet_ntoa (lsa
->data
->id
));
1361 UNSET_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
);
1365 if (IS_DEBUG_OSPF_EVENT
)
1366 zlog_info ("ospf_abr_unapprove_summaries(): Stop");
1370 ospf_abr_prepare_aggregates (struct ospf
*ospf
)
1373 struct route_node
*rn
;
1374 struct ospf_area_range
*range
;
1376 if (IS_DEBUG_OSPF_EVENT
)
1377 zlog_info ("ospf_abr_prepare_aggregates(): Start");
1379 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1381 struct ospf_area
*area
= getdata (node
);
1383 for (rn
= route_top (area
->ranges
); rn
; rn
= route_next (rn
))
1384 if ((range
= rn
->info
) != NULL
)
1387 range
->specifics
= 0;
1391 if (IS_DEBUG_OSPF_EVENT
)
1392 zlog_info ("ospf_abr_prepare_aggregates(): Stop");
1396 ospf_abr_announce_aggregates (struct ospf
*ospf
)
1398 struct ospf_area
*area
, *ar
;
1399 struct ospf_area_range
*range
;
1400 struct route_node
*rn
;
1404 if (IS_DEBUG_OSPF_EVENT
)
1405 zlog_info ("ospf_abr_announce_aggregates(): Start");
1407 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1409 area
= getdata (node
);
1411 if (IS_DEBUG_OSPF_EVENT
)
1412 zlog_info ("ospf_abr_announce_aggregates(): looking at area %s",
1413 inet_ntoa (area
->area_id
));
1415 for (rn
= route_top (area
->ranges
); rn
; rn
= route_next (rn
))
1416 if ((range
= rn
->info
))
1418 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
1420 if (IS_DEBUG_OSPF_EVENT
)
1421 zlog_info ("ospf_abr_announce_aggregates():"
1422 " discarding suppress-ranges");
1427 p
.u
.prefix4
= range
->addr
;
1428 p
.prefixlen
= range
->masklen
;
1430 if (IS_DEBUG_OSPF_EVENT
)
1431 zlog_info ("ospf_abr_announce_aggregates():"
1432 " this is range: %s/%d",
1433 inet_ntoa (p
.u
.prefix4
), p
.prefixlen
);
1435 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
1438 p
.u
.prefix4
= range
->subst_addr
;
1439 p
.prefixlen
= range
->subst_masklen
;
1442 if (range
->specifics
)
1444 if (IS_DEBUG_OSPF_EVENT
)
1445 zlog_info ("ospf_abr_announce_aggregates(): active range");
1447 for (n
= listhead (ospf
->areas
); n
; nextnode (n
))
1453 /* We do not check nexthops here, because
1454 intra-area routes can be associated with
1457 /* backbone routes are not summarized
1458 when announced into transit areas */
1460 if (ospf_area_is_transit (ar
) &&
1461 OSPF_IS_AREA_BACKBONE (area
))
1463 if (IS_DEBUG_OSPF_EVENT
)
1464 zlog_info ("ospf_abr_announce_aggregates(): Skipping "
1465 "announcement of BB aggregate into"
1469 ospf_abr_announce_network_to_area ((struct prefix_ipv4
*)&p
, range
->cost
, ar
);
1475 if (IS_DEBUG_OSPF_EVENT
)
1476 zlog_info ("ospf_abr_announce_aggregates(): Stop");
1480 ospf_abr_send_nssa_aggregates (struct ospf
*ospf
) /* temporarily turned off */
1482 listnode node
; /*, n; */
1483 struct ospf_area
*area
; /*, *ar; */
1484 struct route_node
*rn
;
1485 struct ospf_area_range
*range
;
1486 struct prefix_ipv4 p
;
1488 if (IS_DEBUG_OSPF_NSSA
)
1489 zlog_info ("ospf_abr_send_nssa_aggregates(): Start");
1491 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1493 area
= getdata (node
);
1495 if (! area
->NSSATranslatorState
)
1498 if (IS_DEBUG_OSPF_NSSA
)
1499 zlog_info ("ospf_abr_send_nssa_aggregates(): looking at area %s",
1500 inet_ntoa (area
->area_id
));
1502 for (rn
= route_top (area
->ranges
); rn
; rn
= route_next (rn
))
1504 if (rn
->info
== NULL
)
1509 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
1511 if (IS_DEBUG_OSPF_NSSA
)
1512 zlog_info ("ospf_abr_send_nssa_aggregates():"
1513 " discarding suppress-ranges");
1518 p
.prefix
= range
->addr
;
1519 p
.prefixlen
= range
->masklen
;
1521 if (IS_DEBUG_OSPF_NSSA
)
1522 zlog_info ("ospf_abr_send_nssa_aggregates():"
1523 " this is range: %s/%d",
1524 inet_ntoa (p
.prefix
), p
.prefixlen
);
1526 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
1529 p
.prefix
= range
->subst_addr
;
1530 p
.prefixlen
= range
->subst_masklen
;
1533 if (range
->specifics
)
1535 if (IS_DEBUG_OSPF_NSSA
)
1536 zlog_info ("ospf_abr_send_nssa_aggregates(): active range");
1538 /* Fetch LSA-Type-7 from aggregate prefix, and then
1539 * translate, Install (as Type-5), Approve, and Flood
1541 ospf_abr_translate_nssa_range (&p
, range
->cost
);
1543 } /* all area ranges*/
1546 if (IS_DEBUG_OSPF_NSSA
)
1547 zlog_info ("ospf_abr_send_nssa_aggregates(): Stop");
1551 ospf_abr_announce_nssa_defaults (struct ospf
*ospf
) /* By ABR-Translator */
1554 struct ospf_area
*area
;
1556 if (! IS_OSPF_ABR (ospf
))
1559 if (IS_DEBUG_OSPF_NSSA
)
1560 zlog_info ("ospf_abr_announce_stub_defaults(): Start");
1562 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1564 area
= getdata (node
);
1565 if (IS_DEBUG_OSPF_NSSA
)
1566 zlog_info ("ospf_abr_announce_nssa_defaults(): looking at area %s",
1567 inet_ntoa (area
->area_id
));
1569 if (area
->external_routing
!= OSPF_AREA_NSSA
)
1572 if (OSPF_IS_AREA_BACKBONE (area
))
1573 continue; /* Sanity Check */
1575 /* if (!TranslatorRole continue V 1.0 look for "always" conf */
1576 if (area
->NSSATranslatorState
)
1578 if (IS_DEBUG_OSPF_NSSA
)
1579 zlog_info ("ospf_abr_announce_nssa_defaults(): "
1580 "announcing 0.0.0.0/0 to this nssa");
1581 /* ospf_abr_announce_nssa_asbr_to_as (&p, area->default_cost, area); */
1582 /*ospf_abr_announce_network_to_area (&p, area->default_cost, area);*/
1588 ospf_abr_announce_stub_defaults (struct ospf
*ospf
)
1591 struct ospf_area
*area
;
1592 struct prefix_ipv4 p
;
1594 if (! IS_OSPF_ABR (ospf
))
1597 if (IS_DEBUG_OSPF_EVENT
)
1598 zlog_info ("ospf_abr_announce_stub_defaults(): Start");
1601 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1604 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1606 area
= getdata (node
);
1607 if (IS_DEBUG_OSPF_EVENT
)
1608 zlog_info ("ospf_abr_announce_stub_defaults(): looking at area %s",
1609 inet_ntoa (area
->area_id
));
1611 if ( (area
->external_routing
!= OSPF_AREA_STUB
)
1612 && (area
->external_routing
!= OSPF_AREA_NSSA
)
1616 if (OSPF_IS_AREA_BACKBONE (area
))
1617 continue; /* Sanity Check */
1619 if (IS_DEBUG_OSPF_EVENT
)
1620 zlog_info ("ospf_abr_announce_stub_defaults(): "
1621 "announcing 0.0.0.0/0 to area %s",
1622 inet_ntoa (area
->area_id
));
1623 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1626 if (IS_DEBUG_OSPF_EVENT
)
1627 zlog_info ("ospf_abr_announce_stub_defaults(): Stop");
1631 ospf_abr_remove_unapproved_translates_apply (struct ospf
*ospf
,
1632 struct ospf_lsa
*lsa
)
1634 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
)
1635 && ! CHECK_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
))
1637 zlog_info ("ospf_abr_remove_unapproved_translates(): "
1638 "removing unapproved translates, ID: %s",
1639 inet_ntoa (lsa
->data
->id
));
1641 /* FLUSH THROUGHOUT AS */
1642 ospf_lsa_flush_as (ospf
, lsa
);
1644 /* DISCARD from LSDB */
1650 ospf_abr_remove_unapproved_translates (struct ospf
*ospf
)
1652 struct route_node
*rn
;
1653 struct ospf_lsa
*lsa
;
1655 /* All AREA PROCESS should have APPROVED necessary LSAs */
1656 /* Remove any left over and not APPROVED */
1657 if (IS_DEBUG_OSPF_NSSA
)
1658 zlog_info ("ospf_abr_remove_unapproved_translates(): Start");
1660 LSDB_LOOP (EXTERNAL_LSDB (ospf
), rn
, lsa
)
1661 ospf_abr_remove_unapproved_translates_apply (ospf
, lsa
);
1663 if (IS_DEBUG_OSPF_NSSA
)
1664 zlog_info ("ospf_abr_remove_unapproved_translates(): Stop");
1668 ospf_abr_remove_unapproved_summaries (struct ospf
*ospf
)
1671 struct ospf_area
*area
;
1672 struct route_node
*rn
;
1673 struct ospf_lsa
*lsa
;
1675 if (IS_DEBUG_OSPF_EVENT
)
1676 zlog_info ("ospf_abr_remove_unapproved_summaries(): Start");
1678 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1680 area
= getdata (node
);
1682 if (IS_DEBUG_OSPF_EVENT
)
1683 zlog_info ("ospf_abr_remove_unapproved_summaries(): "
1684 "looking at area %s", inet_ntoa (area
->area_id
));
1686 LSDB_LOOP (SUMMARY_LSDB (area
), rn
, lsa
)
1687 if (ospf_lsa_is_self_originated (ospf
, lsa
))
1688 if (!CHECK_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
))
1689 ospf_lsa_flush_area (lsa
, area
);
1691 LSDB_LOOP (ASBR_SUMMARY_LSDB (area
), rn
, lsa
)
1692 if (ospf_lsa_is_self_originated (ospf
, lsa
))
1693 if (!CHECK_FLAG (lsa
->flags
, OSPF_LSA_APPROVED
))
1694 ospf_lsa_flush_area (lsa
, area
);
1697 if (IS_DEBUG_OSPF_EVENT
)
1698 zlog_info ("ospf_abr_remove_unapproved_summaries(): Stop");
1702 ospf_abr_manage_discard_routes (struct ospf
*ospf
)
1705 struct route_node
*rn
;
1706 struct ospf_area
*area
;
1707 struct ospf_area_range
*range
;
1709 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
1710 if ((area
= node
->data
) != NULL
)
1711 for (rn
= route_top (area
->ranges
); rn
; rn
= route_next (rn
))
1712 if ((range
= rn
->info
) != NULL
)
1713 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
1715 if (range
->specifics
)
1716 ospf_add_discard_route (ospf
->new_table
, area
,
1717 (struct prefix_ipv4
*) &rn
->p
);
1719 ospf_delete_discard_route ((struct prefix_ipv4
*) &rn
->p
);
1723 /* This is the function taking care about ABR NSSA, i.e. NSSA
1724 Translator, -LSA aggregation and flooding. For all NSSAs
1726 Any SELF-AS-LSA is in the Type-5 LSDB and Type-7 LSDB. These LSA's
1727 are refreshed from the Type-5 LSDB, installed into the Type-7 LSDB
1730 Any received Type-5s are legal for an ABR, else illegal for IR.
1731 Received Type-7s are installed, by area, with incoming P-bit. They
1732 are flooded; if the Elected NSSA Translator, then P-bit off.
1734 Additionally, this ABR will place "translated type-7's" into the
1735 Type-5 LSDB in order to keep track of APPROVAL or not.
1737 It will scan through every area, looking for Type-7 LSAs with P-Bit
1738 SET. The Type-7's are either AS-FLOODED & 5-INSTALLED or
1739 AGGREGATED. Later, the AGGREGATED LSAs are AS-FLOODED &
1742 5-INSTALLED is into the Type-5 LSDB; Any UNAPPROVED Type-5 LSAs
1743 left over are FLUSHED and DISCARDED.
1745 For External Calculations, any NSSA areas use the Type-7 AREA-LSDB,
1746 any ABR-non-NSSA areas use the Type-5 GLOBAL-LSDB. */
1749 ospf_abr_nssa_task (struct ospf
*ospf
) /* called only if any_nssa */
1751 if (IS_DEBUG_OSPF_NSSA
)
1752 zlog_info ("Check for NSSA-ABR Tasks():");
1754 if (! IS_OSPF_ABR (ospf
))
1757 if (! ospf
->anyNSSA
)
1760 /* Each area must confirm TranslatorRole */
1761 if (IS_DEBUG_OSPF_NSSA
)
1762 zlog_info ("ospf_abr_nssa_task(): Start");
1764 /* For all Global Entries flagged "local-translate", unset APPROVED */
1765 if (IS_DEBUG_OSPF_NSSA
)
1766 zlog_info ("ospf_abr_nssa_task(): unapprove translates");
1768 ospf_abr_unapprove_translates (ospf
);
1770 /* RESET all Ranges in every Area, same as summaries */
1771 if (IS_DEBUG_OSPF_NSSA
)
1772 zlog_info ("ospf_abr_nssa_task(): NSSA initialize aggregates");
1773 ospf_abr_prepare_aggregates (ospf
); /*TURNED OFF just for now */
1775 /* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or
1776 * Aggregate as Type-7
1777 * Install or Approve in Type-5 Global LSDB
1779 if (IS_DEBUG_OSPF_NSSA
)
1780 zlog_info ("ospf_abr_nssa_task(): process translates");
1781 ospf_abr_process_nssa_translates (ospf
);
1783 /* Translate/Send any "ranged" aggregates, and also 5-Install and
1785 * Scan Type-7's for aggregates, translate to Type-5's,
1786 * Install/Flood/Approve
1788 if (IS_DEBUG_OSPF_NSSA
)
1789 zlog_info("ospf_abr_nssa_task(): send NSSA aggregates");
1790 ospf_abr_send_nssa_aggregates (ospf
); /*TURNED OFF FOR NOW */
1792 /* Send any NSSA defaults as Type-5
1793 *if (IS_DEBUG_OSPF_NSSA)
1794 * zlog_info ("ospf_abr_nssa_task(): announce nssa defaults");
1795 *ospf_abr_announce_nssa_defaults (ospf);
1796 * havnt a clue what above is supposed to do.
1799 /* Flush any unapproved previous translates from Global Data Base */
1800 if (IS_DEBUG_OSPF_NSSA
)
1801 zlog_info ("ospf_abr_nssa_task(): remove unapproved translates");
1802 ospf_abr_remove_unapproved_translates (ospf
);
1804 ospf_abr_manage_discard_routes (ospf
); /* same as normal...discard */
1806 if (IS_DEBUG_OSPF_NSSA
)
1807 zlog_info ("ospf_abr_nssa_task(): Stop");
1810 /* This is the function taking care about ABR stuff, i.e.
1811 summary-LSA origination and flooding. */
1813 ospf_abr_task (struct ospf
*ospf
)
1815 if (IS_DEBUG_OSPF_EVENT
)
1816 zlog_info ("ospf_abr_task(): Start");
1818 if (ospf
->new_table
== NULL
|| ospf
->new_rtrs
== NULL
)
1820 if (IS_DEBUG_OSPF_EVENT
)
1821 zlog_info ("ospf_abr_task(): Routing tables are not yet ready");
1825 if (IS_DEBUG_OSPF_EVENT
)
1826 zlog_info ("ospf_abr_task(): unapprove summaries");
1827 ospf_abr_unapprove_summaries (ospf
);
1829 if (IS_DEBUG_OSPF_EVENT
)
1830 zlog_info ("ospf_abr_task(): prepare aggregates");
1831 ospf_abr_prepare_aggregates (ospf
);
1833 if (IS_OSPF_ABR (ospf
))
1835 if (IS_DEBUG_OSPF_EVENT
)
1836 zlog_info ("ospf_abr_task(): process network RT");
1837 ospf_abr_process_network_rt (ospf
, ospf
->new_table
);
1839 if (IS_DEBUG_OSPF_EVENT
)
1840 zlog_info ("ospf_abr_task(): process router RT");
1841 ospf_abr_process_router_rt (ospf
, ospf
->new_rtrs
);
1843 if (IS_DEBUG_OSPF_EVENT
)
1844 zlog_info ("ospf_abr_task(): announce aggregates");
1845 ospf_abr_announce_aggregates (ospf
);
1847 if (IS_DEBUG_OSPF_EVENT
)
1848 zlog_info ("ospf_abr_task(): announce stub defaults");
1849 ospf_abr_announce_stub_defaults (ospf
);
1852 if (IS_DEBUG_OSPF_EVENT
)
1853 zlog_info ("ospf_abr_task(): remove unapproved summaries");
1854 ospf_abr_remove_unapproved_summaries (ospf
);
1856 ospf_abr_manage_discard_routes (ospf
);
1858 if (IS_DEBUG_OSPF_EVENT
)
1859 zlog_info ("ospf_abr_task(): Stop");
1864 ospf_abr_task_timer (struct thread
*thread
)
1866 struct ospf
*ospf
= THREAD_ARG (thread
);
1868 ospf
->t_abr_task
= 0;
1870 if (IS_DEBUG_OSPF_EVENT
)
1871 zlog_info ("Running ABR task on timer");
1873 ospf_check_abr_status (ospf
);
1874 ospf_abr_nssa_check_status (ospf
);
1876 ospf_abr_task (ospf
);
1877 ospf_abr_nssa_task (ospf
); /* if nssa-abr, then scan Type-7 LSDB */
1883 ospf_schedule_abr_task (struct ospf
*ospf
)
1885 if (IS_DEBUG_OSPF_EVENT
)
1886 zlog_info ("Scheduling ABR task");
1888 if (ospf
->t_abr_task
== NULL
)
1889 ospf
->t_abr_task
= thread_add_timer (master
, ospf_abr_task_timer
,
1890 ospf
, OSPF_ABR_TASK_DELAY
);