summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_abr.c299
-rw-r--r--ospfd/ospf_abr.h8
-rw-r--r--ospfd/ospf_asbr.c38
-rw-r--r--ospfd/ospf_asbr.h13
-rw-r--r--ospfd/ospf_ase.c104
-rw-r--r--ospfd/ospf_ase.h10
-rw-r--r--ospfd/ospf_flood.c151
-rw-r--r--ospfd/ospf_flood.h24
-rw-r--r--ospfd/ospf_ia.c149
-rw-r--r--ospfd/ospf_ia.h3
-rw-r--r--ospfd/ospf_interface.c121
-rw-r--r--ospfd/ospf_interface.h36
-rw-r--r--ospfd/ospf_lsa.c809
-rw-r--r--ospfd/ospf_lsa.h68
-rw-r--r--ospfd/ospf_lsdb.h5
-rw-r--r--ospfd/ospf_neighbor.h4
-rw-r--r--ospfd/ospf_opaque.c43
-rw-r--r--ospfd/ospf_packet.c101
-rw-r--r--ospfd/ospf_route.c50
-rw-r--r--ospfd/ospf_route.h12
-rw-r--r--ospfd/ospf_routemap.c10
-rw-r--r--ospfd/ospf_snmp.c113
-rw-r--r--ospfd/ospf_spf.c102
-rw-r--r--ospfd/ospf_spf.h2
-rw-r--r--ospfd/ospf_te.c16
-rw-r--r--ospfd/ospf_vty.c610
-rw-r--r--ospfd/ospf_zebra.c237
-rw-r--r--ospfd/ospf_zebra.h12
-rw-r--r--ospfd/ospfd.c274
-rw-r--r--ospfd/ospfd.h41
30 files changed, 1799 insertions, 1666 deletions
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index ec3b153c..6799c836 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -203,7 +203,7 @@ ospf_area_range_set (struct ospf *ospf, struct in_addr area_id,
struct ospf_area_range *range;
int ret = OSPF_AREA_ID_FORMAT_DECIMAL;
- area = ospf_area_get (area_id, ret);
+ area = ospf_area_get (ospf, area_id, ret);
if (area == NULL)
return 0;
@@ -214,13 +214,13 @@ ospf_area_range_set (struct ospf *ospf, struct in_addr area_id,
&& !CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))
|| (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)
&& CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE)))
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
else
{
range = ospf_area_range_new (p);
ospf_area_range_add (area, range);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
if (CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))
@@ -239,7 +239,7 @@ ospf_area_range_cost_set (struct ospf *ospf, struct in_addr area_id,
struct ospf_area_range *range;
int ret = OSPF_AREA_ID_FORMAT_DECIMAL;
- area = ospf_area_get (area_id, ret);
+ area = ospf_area_get (ospf, area_id, ret);
if (area == NULL)
return 0;
@@ -251,7 +251,7 @@ ospf_area_range_cost_set (struct ospf *ospf, struct in_addr area_id,
{
range->cost_config = cost;
if (ospf_area_range_active (range))
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
return 1;
@@ -264,7 +264,7 @@ ospf_area_range_unset (struct ospf *ospf, struct in_addr area_id,
struct ospf_area *area;
struct ospf_area_range *range;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 0;
@@ -273,7 +273,7 @@ ospf_area_range_unset (struct ospf *ospf, struct in_addr area_id,
return 0;
if (ospf_area_range_active (range))
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
ospf_area_range_delete (area, range);
@@ -288,20 +288,20 @@ ospf_area_range_substitute_set (struct ospf *ospf, struct in_addr area_id,
struct ospf_area_range *range;
int ret = OSPF_AREA_ID_FORMAT_DECIMAL;
- area = ospf_area_get (area_id, ret);
+ area = ospf_area_get (ospf, area_id, ret);
range = ospf_area_range_lookup (area, p);
if (range != NULL)
{
if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE) ||
!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
else
{
range = ospf_area_range_new (p);
ospf_area_range_add (area, range);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
@@ -319,7 +319,7 @@ ospf_area_range_substitute_unset (struct ospf *ospf, struct in_addr area_id,
struct ospf_area *area;
struct ospf_area_range *range;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 0;
@@ -329,7 +329,7 @@ ospf_area_range_substitute_unset (struct ospf *ospf, struct in_addr area_id,
if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
if (ospf_area_range_active (range))
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
UNSET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE);
range->subst_addr.s_addr = 0;
@@ -339,17 +339,17 @@ ospf_area_range_substitute_unset (struct ospf *ospf, struct in_addr area_id,
}
int
-ospf_act_bb_connection ()
+ospf_act_bb_connection (struct ospf *ospf)
{
- if (ospf_top->backbone == NULL)
+ if (ospf->backbone == NULL)
return 0;
- return ospf_top->backbone->full_nbrs;
+ return ospf->backbone->full_nbrs;
}
/* Check area border router status. */
void
-ospf_check_abr_status ()
+ospf_check_abr_status (struct ospf *ospf)
{
struct ospf_area *area;
listnode node;
@@ -357,13 +357,12 @@ ospf_check_abr_status ()
int bb_act_attached = 0;
int areas_configured = 0;
int areas_act_attached = 0;
-
- u_char new_flags = ospf_top->flags;
+ u_char new_flags = ospf->flags;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_check_abr_status(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -396,7 +395,7 @@ ospf_check_abr_status ()
areas_act_attached);
}
- switch (ospf_top->abr_type)
+ switch (ospf->abr_type)
{
case OSPF_ABR_SHORTCUT:
case OSPF_ABR_STAND:
@@ -423,13 +422,13 @@ ospf_check_abr_status ()
break;
}
- if (new_flags != ospf_top->flags)
+ if (new_flags != ospf->flags)
{
- ospf_spf_calculate_schedule ();
+ ospf_spf_calculate_schedule (ospf);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_check_abr_status(): new router flags: %x",new_flags);
- ospf_top->flags = new_flags;
- OSPF_TIMER_ON (ospf_top->t_router_lsa_update,
+ ospf->flags = new_flags;
+ OSPF_TIMER_ON (ospf->t_router_lsa_update,
ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
}
}
@@ -490,7 +489,7 @@ ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost,
/* ospf_abr_translate_nssa */
int
-ospf_abr_translate_nssa (struct ospf_lsa *lsa, void *p_arg, int int_arg)
+ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa)
{
/* Incoming Type-7 or later aggregated Type-7
@@ -531,9 +530,9 @@ ospf_abr_translate_nssa (struct ospf_lsa *lsa, void *p_arg, int int_arg)
ospf_lsa_checksum (dup->data);
- ospf_lsa_install (NULL, dup); /* Install this Type-5 into LSDB, Lock = 2. */
+ ospf_lsa_install (area->ospf, NULL, dup); /* Install this Type-5 into LSDB, Lock = 2. */
- ospf_flood_through_as (NULL, dup); /* flood non-NSSA/STUB areas */
+ ospf_flood_through_as (area->ospf, NULL, dup); /* flood non-NSSA/STUB areas */
/* This translated Type-5 will go to all non-NSSA areas connected to
this ABR; The Type-5 could come from any of the NSSA's connected
@@ -560,8 +559,8 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_announce_network_to_area(): Start");
- old = OSPF_SUMMARY_LSA_SELF_FIND_BY_PREFIX (area, p);
-
+ old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA, p,
+ area->ospf->router_id);
if (old)
{
if (IS_DEBUG_OSPF_EVENT)
@@ -590,7 +589,7 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
{
set_metric (old, cost);
- lsa = ospf_summary_lsa_refresh (old);
+ lsa = ospf_summary_lsa_refresh (area->ospf, old);
/* This will flood through area. */
}
else
@@ -682,21 +681,22 @@ ospf_abr_plist_out_check (struct ospf_area *area, struct ospf_route *or,
}
void
-ospf_abr_announce_network (struct route_node *n, struct ospf_route *or)
+ospf_abr_announce_network (struct ospf *ospf,
+ struct route_node *n, struct ospf_route *or)
{
- listnode node;
struct ospf_area_range *range;
- struct prefix_ipv4 *p;
struct ospf_area *area, *or_area;
+ struct prefix_ipv4 *p;
+ listnode node;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_announce_network(): Start");
p = (struct prefix_ipv4 *) &n->p;
- or_area = ospf_area_lookup_by_area_id (or->u.std.area_id);
+ or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
assert (or_area);
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -764,9 +764,12 @@ ospf_abr_announce_network (struct route_node *n, struct ospf_route *or)
}
int
-ospf_abr_should_announce (struct prefix *p, struct ospf_route *or)
+ospf_abr_should_announce (struct ospf *ospf,
+ struct prefix *p, struct ospf_route *or)
{
- struct ospf_area *area = ospf_area_lookup_by_area_id (or->u.std.area_id);
+ struct ospf_area *area;
+
+ area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
assert (area);
@@ -785,7 +788,7 @@ ospf_abr_should_announce (struct prefix *p, struct ospf_route *or)
#ifdef HAVE_NSSA
void
-ospf_abr_process_nssa_translates ()
+ospf_abr_process_nssa_translates (struct ospf *ospf)
{
/* Scan through all NSSA_LSDB records for all areas;
@@ -795,11 +798,13 @@ ospf_abr_process_nssa_translates ()
remaining UNAPPROVED Type-5's (Aggregate is for future ) */
listnode node;
struct ospf_area *area;
+ struct route_node *rn;
+ struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_process_nssa_translates(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -813,7 +818,8 @@ ospf_abr_process_nssa_translates ()
zlog_info ("ospf_abr_process_nssa_translates(): "
"looking at area %s", inet_ntoa (area->area_id));
- foreach_lsa (NSSA_LSDB (area), area, 0, ospf_abr_translate_nssa);
+ LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
+ ospf_abr_translate_nssa (area, lsa);
}
if (IS_DEBUG_OSPF_NSSA)
@@ -823,11 +829,12 @@ ospf_abr_process_nssa_translates ()
#endif /* HAVE_NSSA */
void
-ospf_abr_process_network_rt (struct route_table *rt)
+ospf_abr_process_network_rt (struct ospf *ospf,
+ struct route_table *rt)
{
- struct route_node *rn;
- struct ospf_route *or;
struct ospf_area *area;
+ struct ospf_route *or;
+ struct route_node *rn;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_process_network_rt(): Start");
@@ -837,7 +844,7 @@ ospf_abr_process_network_rt (struct route_table *rt)
if ((or = rn->info) == NULL)
continue;
- if (!(area = ospf_area_lookup_by_area_id (or->u.std.area_id)))
+ if (!(area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id)))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_process_network_rt(): area %s no longer exists",
@@ -873,7 +880,7 @@ ospf_abr_process_network_rt (struct route_table *rt)
}
if (or->path_type == OSPF_PATH_INTRA_AREA &&
- !ospf_abr_should_announce (&rn->p, or))
+ !ospf_abr_should_announce (ospf, &rn->p, or))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info("ospf_abr_process_network_rt(): denied by export-list");
@@ -898,10 +905,10 @@ ospf_abr_process_network_rt (struct route_table *rt)
}
- if ((ospf_top->abr_type == OSPF_ABR_CISCO) ||
- (ospf_top->abr_type == OSPF_ABR_IBM))
+ if ((ospf->abr_type == OSPF_ABR_CISCO) ||
+ (ospf->abr_type == OSPF_ABR_IBM))
- if (!ospf_act_bb_connection () &&
+ if (!ospf_act_bb_connection (ospf) &&
or->path_type != OSPF_PATH_INTRA_AREA)
{
if (IS_DEBUG_OSPF_EVENT)
@@ -912,7 +919,7 @@ ospf_abr_process_network_rt (struct route_table *rt)
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_process_network_rt(): announcing");
- ospf_abr_announce_network (rn, or);
+ ospf_abr_announce_network (ospf, rn, or);
}
if (IS_DEBUG_OSPF_EVENT)
@@ -929,9 +936,8 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_announce_rtr_to_area(): Start");
- old = OSPF_SUMMARY_ASBR_LSA_SELF_FIND_BY_PREFIX (area, p);
- /* old = ospf_find_self_summary_asbr_lsa_by_prefix (area, p); */
-
+ old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_ASBR_SUMMARY_LSA,
+ p, area->ospf->router_id);
if (old)
{
if (IS_DEBUG_OSPF_EVENT)
@@ -958,7 +964,7 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
if (old)
{
set_metric (old, cost);
- lsa = ospf_summary_asbr_lsa_refresh (old);
+ lsa = ospf_summary_asbr_lsa_refresh (area->ospf, old);
}
else
lsa = ospf_summary_asbr_lsa_originate (p, cost, area);
@@ -980,7 +986,8 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
void
-ospf_abr_announce_rtr (struct prefix_ipv4 *p, struct ospf_route *or)
+ospf_abr_announce_rtr (struct ospf *ospf,
+ struct prefix_ipv4 *p, struct ospf_route *or)
{
listnode node;
struct ospf_area *area;
@@ -988,7 +995,7 @@ ospf_abr_announce_rtr (struct prefix_ipv4 *p, struct ospf_route *or)
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_announce_rtr(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -1034,10 +1041,10 @@ ospf_abr_announce_rtr (struct prefix_ipv4 *p, struct ospf_route *or)
}
void
-ospf_abr_process_router_rt (struct route_table *rt)
+ospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt)
{
- struct route_node *rn;
struct ospf_route *or;
+ struct route_node *rn;
struct list *l;
if (IS_DEBUG_OSPF_EVENT)
@@ -1064,7 +1071,7 @@ ospf_abr_process_router_rt (struct route_table *rt)
if (or == NULL)
continue;
- if (!ospf_area_lookup_by_area_id (or->u.std.area_id))
+ if (!ospf_area_lookup_by_area_id (ospf, or->u.std.area_id))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_process_router_rt(): area %s no longer exists",
@@ -1083,7 +1090,8 @@ ospf_abr_process_router_rt (struct route_table *rt)
if (!flag)
{
- best = ospf_find_asbr_route (rt, (struct prefix_ipv4 *) &rn->p);
+ best = ospf_find_asbr_route (ospf, rt,
+ (struct prefix_ipv4 *) &rn->p);
flag = 1;
}
@@ -1115,10 +1123,10 @@ ospf_abr_process_router_rt (struct route_table *rt)
continue;
}
- if (ospf_top->abr_type == OSPF_ABR_CISCO ||
- ospf_top->abr_type == OSPF_ABR_IBM)
- if (!ospf_act_bb_connection () &&
- or->path_type != OSPF_PATH_INTRA_AREA)
+ if (ospf->abr_type == OSPF_ABR_CISCO
+ || ospf->abr_type == OSPF_ABR_IBM)
+ if (!ospf_act_bb_connection (ospf)
+ && or->path_type != OSPF_PATH_INTRA_AREA)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info("ospf_abr_process_network_rt(): ALT ABR: "
@@ -1126,7 +1134,7 @@ ospf_abr_process_router_rt (struct route_table *rt)
continue;
}
- ospf_abr_announce_rtr ((struct prefix_ipv4 *) &rn->p, or);
+ ospf_abr_announce_rtr (ospf, (struct prefix_ipv4 *) &rn->p, or);
}
@@ -1151,7 +1159,7 @@ ospf_abr_unapprove_translates_apply (struct ospf_lsa *lsa, void *p_arg,
}
void
-ospf_abr_unapprove_translates () /* For NSSA Translations */
+ospf_abr_unapprove_translates (struct ospf *ospf) /* For NSSA Translations */
{
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_unapprove_translates(): Start");
@@ -1159,7 +1167,7 @@ ospf_abr_unapprove_translates () /* For NSSA Translations */
/* NSSA Translator is not checked, because it may have gone away,
and we would want to flush any residuals anyway */
- foreach_lsa (EXTERNAL_LSDB (ospf_top), NULL, 0,
+ foreach_lsa (EXTERNAL_LSDB (ospf), NULL, 0,
ospf_abr_unapprove_translates_apply);
if (IS_DEBUG_OSPF_NSSA)
@@ -1167,32 +1175,27 @@ ospf_abr_unapprove_translates () /* For NSSA Translations */
}
#endif /* HAVE_NSSA */
-int
-ospf_abr_unapprove_summaries_apply (struct ospf_lsa *lsa, void *p_arg,
- int int_arg)
-{
- if (ospf_lsa_is_self_originated (lsa))
- UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
-
- return 0;
-}
-
void
-ospf_abr_unapprove_summaries ()
+ospf_abr_unapprove_summaries (struct ospf *ospf)
{
listnode node;
struct ospf_area *area;
+ struct route_node *rn;
+ struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_unapprove_summaries(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
- foreach_lsa (SUMMARY_LSDB (area), NULL, 0,
- ospf_abr_unapprove_summaries_apply);
- foreach_lsa (ASBR_SUMMARY_LSDB (area), NULL, 0,
- ospf_abr_unapprove_summaries_apply);
+ LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
+ if (ospf_lsa_is_self_originated (ospf, lsa))
+ UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
+
+ LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
+ if (ospf_lsa_is_self_originated (ospf, lsa))
+ UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
}
if (IS_DEBUG_OSPF_EVENT)
@@ -1200,7 +1203,7 @@ ospf_abr_unapprove_summaries ()
}
void
-ospf_abr_prepare_aggregates ()
+ospf_abr_prepare_aggregates (struct ospf *ospf)
{
listnode node;
struct route_node *rn;
@@ -1209,7 +1212,7 @@ ospf_abr_prepare_aggregates ()
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_prepare_aggregates(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = getdata (node);
@@ -1226,7 +1229,7 @@ ospf_abr_prepare_aggregates ()
}
void
-ospf_abr_announce_aggregates ()
+ospf_abr_announce_aggregates (struct ospf *ospf)
{
struct ospf_area *area, *ar;
struct ospf_area_range *range;
@@ -1237,7 +1240,7 @@ ospf_abr_announce_aggregates ()
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_announce_aggregates(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -1277,7 +1280,7 @@ ospf_abr_announce_aggregates ()
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_announce_aggregates(): active range");
- for (n = listhead (ospf_top->areas); n; nextnode (n))
+ for (n = listhead (ospf->areas); n; nextnode (n))
{
ar = getdata (n);
if (ar == area)
@@ -1311,7 +1314,7 @@ ospf_abr_announce_aggregates ()
#ifdef HAVE_NSSA
void
-ospf_abr_send_nssa_aggregates () /* temporarily turned off */
+ospf_abr_send_nssa_aggregates (struct ospf *ospf) /* temporarily turned off */
{
listnode node; /*, n; */
struct ospf_area *area; /*, *ar; */
@@ -1322,7 +1325,7 @@ ospf_abr_send_nssa_aggregates () /* temporarily turned off */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_send_nssa_aggregates(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -1381,7 +1384,7 @@ ospf_abr_send_nssa_aggregates () /* temporarily turned off */
}
void
-ospf_abr_announce_nssa_defaults () /* By ABR-Translator */
+ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */
{
listnode node;
struct ospf_area *area;
@@ -1397,7 +1400,7 @@ ospf_abr_announce_nssa_defaults () /* By ABR-Translator */
p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
p.prefixlen = 0;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
if (IS_DEBUG_OSPF_NSSA)
@@ -1423,7 +1426,7 @@ ospf_abr_announce_nssa_defaults () /* By ABR-Translator */
#endif /* HAVE_NSSA */
void
-ospf_abr_announce_stub_defaults ()
+ospf_abr_announce_stub_defaults (struct ospf *ospf)
{
listnode node;
struct ospf_area *area;
@@ -1439,7 +1442,7 @@ ospf_abr_announce_stub_defaults ()
p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
p.prefixlen = 0;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
if (IS_DEBUG_OSPF_EVENT)
@@ -1471,6 +1474,8 @@ int
ospf_abr_remove_unapproved_translates_apply (struct ospf_lsa *lsa, void *p_arg,
int int_arg)
{
+ struct ospf *ospf = ospf_top;
+
if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)
&& ! CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
{
@@ -1479,7 +1484,7 @@ ospf_abr_remove_unapproved_translates_apply (struct ospf_lsa *lsa, void *p_arg,
inet_ntoa (lsa->data->id));
/* FLUSH THROUGHOUT AS */
- ospf_lsa_flush_as (lsa);
+ ospf_lsa_flush_as (ospf, lsa);
/* DISCARD from LSDB */
}
@@ -1487,14 +1492,14 @@ ospf_abr_remove_unapproved_translates_apply (struct ospf_lsa *lsa, void *p_arg,
}
void
-ospf_abr_remove_unapproved_translates () /* For NSSA Translations */
+ospf_abr_remove_unapproved_translates (struct ospf *ospf) /* For NSSA Translations */
{
/* All AREA PROCESS should have APPROVED necessary LSAs */
/* Remove any left over and not APPROVED */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_remove_unapproved_translates(): Start");
- foreach_lsa (EXTERNAL_LSDB (ospf_top), NULL, 0,
+ foreach_lsa (EXTERNAL_LSDB (ospf), NULL, 0,
ospf_abr_remove_unapproved_translates_apply);
if (IS_DEBUG_OSPF_NSSA)
@@ -1502,36 +1507,18 @@ ospf_abr_remove_unapproved_translates () /* For NSSA Translations */
}
#endif /* HAVE_NSSA */
-int
-ospf_abr_remove_unapproved_summaries_apply (struct ospf_lsa *lsa, void *p_arg,
- int int_arg)
-{
- struct ospf_area *area;
-
- area = (struct ospf_area *) p_arg;
-
- if (ospf_lsa_is_self_originated (lsa) &&
- !CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
- {
- if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("ospf_abr_remove_unapproved_summaries(): "
- "removing unapproved summary, ID: %s",
- inet_ntoa (lsa->data->id));
- ospf_lsa_flush_area (lsa, area);
- }
- return 0;
-}
-
void
-ospf_abr_remove_unapproved_summaries ()
+ospf_abr_remove_unapproved_summaries (struct ospf *ospf)
{
listnode node;
struct ospf_area *area;
+ struct route_node *rn;
+ struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_remove_unapproved_summaries(): Start");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -1539,10 +1526,15 @@ ospf_abr_remove_unapproved_summaries ()
zlog_info ("ospf_abr_remove_unapproved_summaries(): "
"looking at area %s", inet_ntoa (area->area_id));
- foreach_lsa (SUMMARY_LSDB (area), area, 0,
- ospf_abr_remove_unapproved_summaries_apply);
- foreach_lsa (ASBR_SUMMARY_LSDB (area), area, 0,
- ospf_abr_remove_unapproved_summaries_apply);
+ LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
+ if (ospf_lsa_is_self_originated (ospf, lsa))
+ if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
+ ospf_lsa_flush_area (lsa, area);
+
+ LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
+ if (ospf_lsa_is_self_originated (ospf, lsa))
+ if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
+ ospf_lsa_flush_area (lsa, area);
}
if (IS_DEBUG_OSPF_EVENT)
@@ -1550,21 +1542,21 @@ ospf_abr_remove_unapproved_summaries ()
}
void
-ospf_abr_manage_discard_routes ()
+ospf_abr_manage_discard_routes (struct ospf *ospf)
{
listnode node;
struct route_node *rn;
struct ospf_area *area;
struct ospf_area_range *range;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = node->data) != NULL)
for (rn = route_top (area->ranges); rn; rn = route_next (rn))
if ((range = rn->info) != NULL)
if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
{
if (range->specifics)
- ospf_add_discard_route (ospf_top->new_table, area,
+ ospf_add_discard_route (ospf->new_table, area,
(struct prefix_ipv4 *) &rn->p);
else
ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
@@ -1598,7 +1590,7 @@ ospf_abr_manage_discard_routes ()
any ABR-non-NSSA areas use the Type-5 GLOBAL-LSDB. */
void
-ospf_abr_nssa_task () /* called only if any_nssa */
+ospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */
{
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("Check for NSSA-ABR Tasks():");
@@ -1606,7 +1598,7 @@ ospf_abr_nssa_task () /* called only if any_nssa */
if (! OSPF_IS_ABR)
return;
- if (! ospf_top->anyNSSA)
+ if (! ospf->anyNSSA)
return;
/* Each area must confirm TranslatorRole */
@@ -1617,7 +1609,7 @@ ospf_abr_nssa_task () /* called only if any_nssa */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_nssa_task(): unapprove translates");
- ospf_abr_unapprove_translates ();
+ ospf_abr_unapprove_translates (ospf);
/* RESET all Ranges in every Area, same as summaries */
if (IS_DEBUG_OSPF_NSSA)
@@ -1631,7 +1623,7 @@ ospf_abr_nssa_task () /* called only if any_nssa */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_nssa_task(): process translates");
- ospf_abr_process_nssa_translates (ospf_top->new_table);
+ ospf_abr_process_nssa_translates (ospf);
/* Translate/Send any "ranged" aggregates, and also 5-Install and
Approve */
@@ -1644,14 +1636,14 @@ ospf_abr_nssa_task () /* called only if any_nssa */
/* Send any NSSA defaults as Type-5 */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_nssa_task(): announce nssa defaults");
- ospf_abr_announce_nssa_defaults ();
+ ospf_abr_announce_nssa_defaults (ospf);
/* Flush any unapproved previous translates from Global Data Base */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_nssa_task(): remove unapproved translates");
- ospf_abr_remove_unapproved_translates ();
+ ospf_abr_remove_unapproved_translates (ospf);
- ospf_abr_manage_discard_routes (); /* same as normal...discard */
+ ospf_abr_manage_discard_routes (ospf); /* same as normal...discard */
if (IS_DEBUG_OSPF_NSSA)
zlog_info ("ospf_abr_nssa_task(): Stop");
@@ -1661,12 +1653,12 @@ ospf_abr_nssa_task () /* called only if any_nssa */
/* This is the function taking care about ABR stuff, i.e.
summary-LSA origination and flooding. */
void
-ospf_abr_task ()
+ospf_abr_task (struct ospf *ospf)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): Start");
- if (ospf_top->new_table == NULL || ospf_top->new_rtrs == NULL)
+ if (ospf->new_table == NULL || ospf->new_rtrs == NULL)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): Routing tables are not yet ready");
@@ -1675,39 +1667,39 @@ ospf_abr_task ()
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): unapprove summaries");
- ospf_abr_unapprove_summaries ();
+ ospf_abr_unapprove_summaries (ospf);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): prepare aggregates");
- ospf_abr_prepare_aggregates ();
+ ospf_abr_prepare_aggregates (ospf);
if (OSPF_IS_ABR)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): process network RT");
- ospf_abr_process_network_rt (ospf_top->new_table);
+ ospf_abr_process_network_rt (ospf, ospf->new_table);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): process router RT");
- ospf_abr_process_router_rt (ospf_top->new_rtrs);
+ ospf_abr_process_router_rt (ospf, ospf->new_rtrs);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): announce aggregates");
- ospf_abr_announce_aggregates ();
+ ospf_abr_announce_aggregates (ospf);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): announce stub defaults");
- ospf_abr_announce_stub_defaults ();
+ ospf_abr_announce_stub_defaults (ospf);
}
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_task(): remove unapproved summaries");
- ospf_abr_remove_unapproved_summaries ();
+ ospf_abr_remove_unapproved_summaries (ospf);
- ospf_abr_manage_discard_routes ();
+ ospf_abr_manage_discard_routes (ospf);
#ifdef HAVE_NSSA
- ospf_abr_nssa_task(); /* if nssa-abr, then scan Type-7 LSDB */
+ ospf_abr_nssa_task (ospf); /* if nssa-abr, then scan Type-7 LSDB */
#endif /* HAVE_NSSA */
if (IS_DEBUG_OSPF_EVENT)
@@ -1716,26 +1708,29 @@ ospf_abr_task ()
int
-ospf_abr_task_timer (struct thread *t)
+ospf_abr_task_timer (struct thread *thread)
{
- ospf_top->t_abr_task = 0;
+ struct ospf *ospf = THREAD_ARG (thread);
+
+ ospf->t_abr_task = 0;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Running ABR task on timer");
- ospf_check_abr_status ();
+ ospf_check_abr_status (ospf);
- ospf_abr_task ();
+ ospf_abr_task (ospf);
- return 0;
+ return 0;
}
void
-ospf_schedule_abr_task ()
+ospf_schedule_abr_task (struct ospf *ospf)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Scheduling ABR task");
- if (! ospf_top->t_abr_task)
- ospf_top->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,
- 0, OSPF_ABR_TASK_DELAY);
+
+ if (ospf->t_abr_task == NULL)
+ ospf->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,
+ ospf, OSPF_ABR_TASK_DELAY);
}
diff --git a/ospfd/ospf_abr.h b/ospfd/ospf_abr.h
index 3b385c32..c025f514 100644
--- a/ospfd/ospf_abr.h
+++ b/ospfd/ospf_abr.h
@@ -75,10 +75,10 @@ int ospf_area_range_substitute_unset (struct ospf *, struct in_addr,
struct ospf_area_range *ospf_area_range_match_any (struct ospf *,
struct prefix_ipv4 *);
int ospf_area_range_active (struct ospf_area_range *);
-int ospf_act_bb_connection ();
+int ospf_act_bb_connection (struct ospf *);
-void ospf_check_abr_status ();
-void ospf_abr_task ();
-void ospf_schedule_abr_task ();
+void ospf_check_abr_status (struct ospf *);
+void ospf_abr_task (struct ospf *);
+void ospf_schedule_abr_task (struct ospf *);
#endif /* _ZEBRA_OSPF_ABR_H */
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index d13bbc43..c5d199fb 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -43,15 +43,16 @@
#include "ospfd/ospf_route.h"
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_dump.h"
+
/* Remove external route. */
void
-ospf_external_route_remove (struct prefix_ipv4 *p)
+ospf_external_route_remove (struct ospf *ospf, struct prefix_ipv4 *p)
{
struct route_node *rn;
struct ospf_route *or;
- rn = route_node_lookup (ospf_top->old_external_route, (struct prefix *) p);
+ rn = route_node_lookup (ospf->old_external_route, (struct prefix *) p);
if (rn)
if ((or = rn->info))
{
@@ -76,11 +77,12 @@ ospf_external_route_remove (struct prefix_ipv4 *p)
/* Lookup external route. */
struct ospf_route *
-ospf_external_route_lookup (struct prefix_ipv4 *p)
+ospf_external_route_lookup (struct ospf *ospf,
+ struct prefix_ipv4 *p)
{
struct route_node *rn;
- rn = route_node_lookup (ospf_top->old_external_route, (struct prefix *) p);
+ rn = route_node_lookup (ospf->old_external_route, (struct prefix *) p);
if (rn)
{
route_unlock_node (rn);
@@ -203,14 +205,15 @@ ospf_external_info_lookup (u_char type, struct prefix_ipv4 *p)
}
struct ospf_lsa *
-ospf_external_info_find_lsa (struct prefix_ipv4 *p)
+ospf_external_info_find_lsa (struct ospf *ospf,
+ struct prefix_ipv4 *p)
{
struct ospf_lsa *lsa;
struct as_external_lsa *al;
struct in_addr mask, id;
- lsa = ospf_lsdb_lookup_by_id (ospf_top->lsdb, OSPF_AS_EXTERNAL_LSA,
- p->prefix, ospf_top->router_id);
+ lsa = ospf_lsdb_lookup_by_id (ospf->lsdb, OSPF_AS_EXTERNAL_LSA,
+ p->prefix, ospf->router_id);
if (!lsa)
return NULL;
@@ -222,8 +225,8 @@ ospf_external_info_find_lsa (struct prefix_ipv4 *p)
if (mask.s_addr != al->mask.s_addr)
{
id.s_addr = p->prefix.s_addr | (~mask.s_addr);
- lsa = ospf_lsdb_lookup_by_id (ospf_top->lsdb, OSPF_AS_EXTERNAL_LSA,
- id, ospf_top->router_id);
+ lsa = ospf_lsdb_lookup_by_id (ospf->lsdb, OSPF_AS_EXTERNAL_LSA,
+ id, ospf->router_id);
if (!lsa)
return NULL;
}
@@ -234,7 +237,7 @@ ospf_external_info_find_lsa (struct prefix_ipv4 *p)
/* Update ASBR status. */
void
-ospf_asbr_status_update (u_char status)
+ospf_asbr_status_update (struct ospf *ospf, u_char status)
{
zlog_info ("ASBR[Status:%d]: Update", status);
@@ -247,7 +250,7 @@ ospf_asbr_status_update (u_char status)
zlog_info ("ASBR[Status:%d]: Already ASBR", status);
return;
}
- SET_FLAG (ospf_top->flags, OSPF_FLAG_ASBR);
+ SET_FLAG (ospf->flags, OSPF_FLAG_ASBR);
}
else
{
@@ -257,18 +260,19 @@ ospf_asbr_status_update (u_char status)
zlog_info ("ASBR[Status:%d]: Already non ASBR", status);
return;
}
- UNSET_FLAG (ospf_top->flags, OSPF_FLAG_ASBR);
+ UNSET_FLAG (ospf->flags, OSPF_FLAG_ASBR);
}
/* Transition from/to status ASBR, schedule timer. */
- ospf_spf_calculate_schedule ();
- OSPF_TIMER_ON (ospf_top->t_router_lsa_update,
+ ospf_spf_calculate_schedule (ospf);
+ OSPF_TIMER_ON (ospf->t_router_lsa_update,
ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
}
void
ospf_redistribute_withdraw (u_char type)
{
+ struct ospf *ospf = ospf_top;
struct route_node *rn;
struct external_info *ei;
@@ -276,12 +280,12 @@ ospf_redistribute_withdraw (u_char type)
if (EXTERNAL_INFO (type))
for (rn = route_top (EXTERNAL_INFO (type)); rn; rn = route_next (rn))
if ((ei = rn->info))
- if (ospf_external_info_find_lsa (&ei->p))
+ if (ospf_external_info_find_lsa (ospf, &ei->p))
{
if (is_prefix_default (&ei->p) &&
- ospf_top->default_originate != DEFAULT_ORIGINATE_NONE)
+ ospf->default_originate != DEFAULT_ORIGINATE_NONE)
continue;
- ospf_external_lsa_flush (type, &ei->p, ei->ifindex, ei->nexthop);
+ ospf_external_lsa_flush (ospf, type, &ei->p, ei->ifindex, ei->nexthop);
ospf_external_info_delete (type, ei->p);
}
}
diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h
index f368246d..ddfa9fae 100644
--- a/ospfd/ospf_asbr.h
+++ b/ospfd/ospf_asbr.h
@@ -54,22 +54,23 @@ struct external_info
#define OSPF_ASBR_CHECK_DELAY 30
-void ospf_external_route_remove (struct prefix_ipv4 *p);
+void ospf_external_route_remove (struct ospf *, struct prefix_ipv4 *);
struct external_info *ospf_external_info_new (u_char);
-void ospf_reset_route_map_set_values (struct route_map_set_values *values);
-int ospf_route_map_set_compare (struct route_map_set_values *values1,
- struct route_map_set_values *values2);
+void ospf_reset_route_map_set_values (struct route_map_set_values *);
+int ospf_route_map_set_compare (struct route_map_set_values *,
+ struct route_map_set_values *);
struct external_info *ospf_external_info_add (u_char, struct prefix_ipv4,
unsigned int, struct in_addr);
void ospf_external_info_delete (u_char, struct prefix_ipv4);
struct external_info *ospf_external_info_lookup (u_char, struct prefix_ipv4 *);
-void ospf_asbr_status_update (u_char);
+void ospf_asbr_status_update (struct ospf *, u_char);
void ospf_redistribute_withdraw (u_char);
void ospf_asbr_check ();
void ospf_schedule_asbr_check ();
void ospf_asbr_route_install_lsa (struct ospf_lsa *);
-struct ospf_lsa *ospf_external_info_find_lsa (struct prefix_ipv4 *p);
+struct ospf_lsa *ospf_external_info_find_lsa (struct ospf *,
+ struct prefix_ipv4 *p);
#endif /* _ZEBRA_OSPF_ASBR_H */
diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c
index 9194c566..b28626db 100644
--- a/ospfd/ospf_ase.c
+++ b/ospfd/ospf_ase.c
@@ -49,7 +49,8 @@
#define DEBUG
struct ospf_route *
-ospf_find_asbr_route (struct route_table *rtrs, struct prefix_ipv4 *asbr)
+ospf_find_asbr_route (struct ospf *ospf,
+ struct route_table *rtrs, struct prefix_ipv4 *asbr)
{
struct route_node *rn;
struct ospf_route *or, *best = NULL;
@@ -69,7 +70,7 @@ ospf_find_asbr_route (struct route_table *rtrs, struct prefix_ipv4 *asbr)
chosen = list_new ();
/* First try to find intra-area non-bb paths. */
- if (!CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE))
+ if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
for (node = listhead ((list) rn->info); node; nextnode (node))
if ((or = getdata (node)) != NULL)
if (or->cost < OSPF_LS_INFINITY)
@@ -147,12 +148,12 @@ ospf_ase_complete_direct_routes (struct ospf_route *ro, struct in_addr nexthop)
}
int
-ospf_ase_forward_address_check (struct in_addr fwd_addr)
+ospf_ase_forward_address_check (struct ospf *ospf, struct in_addr fwd_addr)
{
listnode ifn;
struct ospf_interface *oi;
- for (ifn = listhead (ospf_top->oiflist); ifn; nextnode (ifn))
+ for (ifn = listhead (ospf->oiflist); ifn; nextnode (ifn))
if ((oi = getdata (ifn)) != NULL)
if (if_is_up (oi->ifp))
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
@@ -164,7 +165,8 @@ ospf_ase_forward_address_check (struct in_addr fwd_addr)
/* Calculate ASBR route. */
struct ospf_route *
-ospf_ase_calculate_asbr_route (struct route_table *rt_network,
+ospf_ase_calculate_asbr_route (struct ospf *ospf,
+ struct route_table *rt_network,
struct route_table *rt_router,
struct as_external_lsa *al)
{
@@ -178,7 +180,7 @@ ospf_ase_calculate_asbr_route (struct route_table *rt_network,
asbr.prefixlen = IPV4_MAX_BITLEN;
apply_mask_ipv4 (&asbr);
- asbr_route = ospf_find_asbr_route (rt_router, &asbr);
+ asbr_route = ospf_find_asbr_route (ospf, rt_router, &asbr);
if (asbr_route == NULL)
{
@@ -198,7 +200,7 @@ ospf_ase_calculate_asbr_route (struct route_table *rt_network,
zlog_info ("ospf_ase_calculate(): "
"Forwarding address is not 0.0.0.0.");
- if (! ospf_ase_forward_address_check (al->e[0].fwd_addr))
+ if (! ospf_ase_forward_address_check (ospf, al->e[0].fwd_addr))
{
zlog_info ("ospf_ase_calculate(): "
"Forwarding address is one of our addresses, Ignore.");
@@ -279,7 +281,7 @@ ospf_ase_calculate_new_route (struct ospf_lsa *lsa,
#define OSPF_ASE_CALC_INTERVAL 1
int
-ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
+ospf_ase_calculate_route (struct ospf *ospf, struct ospf_lsa * lsa)
{
u_int32_t metric;
struct as_external_lsa *al;
@@ -343,7 +345,7 @@ ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
asbr.prefixlen = IPV4_MAX_BITLEN;
apply_mask_ipv4 (&asbr);
- asbr_route = ospf_find_asbr_route (ospf_top->new_rtrs, &asbr);
+ asbr_route = ospf_find_asbr_route (ospf, ospf->new_rtrs, &asbr);
if (asbr_route == NULL)
{
zlog_info ("Route[External]: Can't find originating ASBR route");
@@ -383,7 +385,7 @@ ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
routing table entry must specify an intra-area or inter-area
path; if no such path exists, do nothing with the LSA and
consider the next in the list. */
- if (! ospf_ase_forward_address_check (al->e[0].fwd_addr))
+ if (! ospf_ase_forward_address_check (ospf, al->e[0].fwd_addr))
{
zlog_info ("Route[External]: Forwarding address is our router address");
return 0;
@@ -393,7 +395,7 @@ ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
asbr.prefix = al->e[0].fwd_addr;
asbr.prefixlen = IPV4_MAX_BITLEN;
- rn = route_node_match (ospf_top->new_table, (struct prefix *) &asbr);
+ rn = route_node_match (ospf->new_table, (struct prefix *) &asbr);
if (rn == NULL || (asbr_route = rn->info) == NULL)
{
@@ -437,7 +439,7 @@ ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
/* if there is a Intra/Inter area route to the N
do not install external route */
- if ((rn = route_node_lookup (ospf_top->new_table,
+ if ((rn = route_node_lookup (ospf->new_table,
(struct prefix *) &p)) != NULL
&& (rn->info != NULL))
{
@@ -448,14 +450,14 @@ ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
/* Find a route to the same dest */
/* If there is no route, create new one. */
- if ((rn = route_node_lookup (ospf_top->new_external_route,
+ if ((rn = route_node_lookup (ospf->new_external_route,
(struct prefix *) &p)) == NULL
|| (or = rn->info) == NULL)
{
zlog_info ("Route[External]: Adding a new route %s/%d",
inet_ntoa (p.prefix), p.prefixlen);
- ospf_route_add (ospf_top->new_external_route, &p, new, asbr_route);
+ ospf_route_add (ospf->new_external_route, &p, new, asbr_route);
if (al->e[0].fwd_addr.s_addr)
ospf_ase_complete_direct_routes (new, al->e[0].fwd_addr);
@@ -470,7 +472,7 @@ ospf_ase_calculate_route (struct ospf_lsa * lsa, void * p_arg, int n_arg)
external paths. When all paths are type 2 external
paths, the paths with the smallest advertised type 2
metric are always preferred. */
- ret = ospf_route_cmp (new, or);
+ ret = ospf_route_cmp (ospf, new, or);
/* (c) If the new AS external path is still indistinguishable
from the current paths in the N's routing table entry,
@@ -610,10 +612,11 @@ int
ospf_ase_calculate_timer (struct thread *t)
{
struct ospf *ospf;
-
+ struct ospf_lsa *lsa;
+ struct route_node *rn;
#ifdef HAVE_NSSA
- listnode node;
- struct ospf_area *area;
+ listnode node;
+ struct ospf_area *area;
#endif /* HAVE_NSSA */
ospf = THREAD_ARG (t);
@@ -624,13 +627,13 @@ ospf_ase_calculate_timer (struct thread *t)
ospf->ase_calc = 0;
/* Calculate external route for each AS-external-LSA */
- foreach_lsa (EXTERNAL_LSDB (ospf_top), NULL, 0,
- ospf_ase_calculate_route);
+ LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
+ ospf_ase_calculate_route (ospf, lsa);
#ifdef HAVE_NSSA
/* This version simple adds to the table all NSSA areas */
- if (ospf_top->anyNSSA)
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ if (ospf->anyNSSA)
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
if (IS_DEBUG_OSPF_NSSA)
@@ -638,43 +641,42 @@ ospf_ase_calculate_timer (struct thread *t)
inet_ntoa (area->area_id));
if (area->external_routing == OSPF_AREA_NSSA)
-
- foreach_lsa (NSSA_LSDB (area), NULL, 0,
- ospf_ase_calculate_route);
+ LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
+ ospf_ase_calculate_route (ospf, lsa);
}
#endif /* HAVE_NSSA */
/* Compare old and new external routing table and install the
difference info zebra/kernel */
- ospf_ase_compare_tables (ospf_top->new_external_route,
- ospf_top->old_external_route);
+ ospf_ase_compare_tables (ospf->new_external_route,
+ ospf->old_external_route);
/* Delete old external routing table */
- ospf_route_table_free (ospf_top->old_external_route);
- ospf_top->old_external_route = ospf_top->new_external_route;
- ospf_top->new_external_route = route_table_init ();
+ ospf_route_table_free (ospf->old_external_route);
+ ospf->old_external_route = ospf->new_external_route;
+ ospf->new_external_route = route_table_init ();
}
return 0;
}
void
-ospf_ase_calculate_schedule ()
+ospf_ase_calculate_schedule (struct ospf *ospf)
{
- if (! ospf_top)
+ if (ospf == NULL)
return;
- ospf_top->ase_calc = 1;
+ ospf->ase_calc = 1;
}
void
-ospf_ase_calculate_timer_add ()
+ospf_ase_calculate_timer_add (struct ospf *ospf)
{
- if (! ospf_top)
+ if (ospf == NULL)
return;
- if (! ospf_top->t_ase_calc)
- ospf_top->t_ase_calc = thread_add_timer (master, ospf_ase_calculate_timer,
- ospf_top, OSPF_ASE_CALC_INTERVAL);
+ if (! ospf->t_ase_calc)
+ ospf->t_ase_calc = thread_add_timer (master, ospf_ase_calculate_timer,
+ ospf, OSPF_ASE_CALC_INTERVAL);
}
void
@@ -752,7 +754,7 @@ ospf_ase_external_lsas_finish (struct route_table *rt)
}
void
-ospf_ase_incremental_update (struct ospf_lsa *lsa, struct ospf *top)
+ospf_ase_incremental_update (struct ospf *ospf, struct ospf_lsa *lsa)
{
list lsas;
listnode node;
@@ -769,31 +771,31 @@ ospf_ase_incremental_update (struct ospf_lsa *lsa, struct ospf *top)
/* if new_table is NULL, there was no spf calculation, thus
incremental update is unneeded */
- if (!top->new_table)
+ if (!ospf->new_table)
return;
/* If there is already an intra-area or inter-area route
to the destination, no recalculation is necessary
(internal routes take precedence). */
- rn = route_node_lookup (top->new_table, (struct prefix *) &p);
+ rn = route_node_lookup (ospf->new_table, (struct prefix *) &p);
if (rn && rn->info)
{
route_unlock_node (rn);
return;
}
- rn = route_node_lookup (top->external_lsas, (struct prefix *) &p);
+ rn = route_node_lookup (ospf->external_lsas, (struct prefix *) &p);
assert (rn && rn->info);
lsas = rn->info;
for (node = listhead (lsas); node; nextnode (node))
if ((lsa = getdata (node)) != NULL)
- ospf_ase_calculate_route (lsa, NULL, 0);
+ ospf_ase_calculate_route (ospf, lsa);
/* prepare temporary old routing table for compare */
tmp_old = route_table_init ();
- rn = route_node_lookup (top->old_external_route, (struct prefix *) &p);
+ rn = route_node_lookup (ospf->old_external_route, (struct prefix *) &p);
if (rn && rn->info)
{
rn2 = route_node_get (tmp_old, (struct prefix *) &p);
@@ -801,23 +803,23 @@ ospf_ase_incremental_update (struct ospf_lsa *lsa, struct ospf *top)
}
/* install changes to zebra */
- ospf_ase_compare_tables (top->new_external_route, tmp_old);
+ ospf_ase_compare_tables (ospf->new_external_route, tmp_old);
- /* update top->old_external_route table */
+ /* update ospf->old_external_route table */
if (rn && rn->info)
ospf_route_free ((struct ospf_route *) rn->info);
- rn2 = route_node_lookup (top->new_external_route, (struct prefix *) &p);
- /* if new route exists, install it to top->old_external_route */
+ rn2 = route_node_lookup (ospf->new_external_route, (struct prefix *) &p);
+ /* if new route exists, install it to ospf->old_external_route */
if (rn2 && rn2->info)
{
if (!rn)
- rn = route_node_get (top->old_external_route, (struct prefix *) &p);
+ rn = route_node_get (ospf->old_external_route, (struct prefix *) &p);
rn->info = rn2->info;
}
else
{
- /* remove route node from top->old_external_route */
+ /* remove route node from ospf->old_external_route */
if (rn)
{
rn->info = NULL;
@@ -828,7 +830,7 @@ ospf_ase_incremental_update (struct ospf_lsa *lsa, struct ospf *top)
if (rn2)
{
- /* rn2->info is stored in route node of top->old_external_route */
+ /* rn2->info is stored in route node of ospf->old_external_route */
rn2->info = NULL;
route_unlock_node (rn2);
route_unlock_node (rn2);
diff --git a/ospfd/ospf_ase.h b/ospfd/ospf_ase.h
index f403e26d..d2fee1a1 100644
--- a/ospfd/ospf_ase.h
+++ b/ospfd/ospf_ase.h
@@ -24,18 +24,18 @@
#define _ZEBRA_OSPF_ASE_H
-struct ospf_route *ospf_find_asbr_route (struct route_table *,
+struct ospf_route *ospf_find_asbr_route (struct ospf *, struct route_table *,
struct prefix_ipv4 *);
struct ospf_route *ospf_find_asbr_route_through_area(struct route_table *,
struct prefix_ipv4 *,
struct ospf_area *);
-int ospf_ase_calculate_route (struct ospf_lsa *, void *, int);
-void ospf_ase_calculate_schedule ();
-void ospf_ase_calculate_timer_add ();
+int ospf_ase_calculate_route (struct ospf *, struct ospf_lsa *);
+void ospf_ase_calculate_schedule (struct ospf *);
+void ospf_ase_calculate_timer_add (struct ospf *);
void ospf_ase_external_lsas_finish (struct route_table *);
-void ospf_ase_incremental_update (struct ospf_lsa *, struct ospf *);
+void ospf_ase_incremental_update (struct ospf *, struct ospf_lsa *);
void ospf_ase_register_external_lsa (struct ospf_lsa *, struct ospf *);
void ospf_ase_unregister_external_lsa (struct ospf_lsa *, struct ospf *);
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index bd33c345..cf88761e 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -111,7 +111,8 @@ ospf_external_info_check (struct ospf_lsa *lsa)
}
void
-ospf_process_self_originated_lsa (struct ospf_lsa *new, struct ospf_area *area)
+ospf_process_self_originated_lsa (struct ospf *ospf,
+ struct ospf_lsa *new, struct ospf_area *area)
{
struct ospf_interface *oi;
struct external_info *ei;
@@ -148,7 +149,7 @@ ospf_process_self_originated_lsa (struct ospf_lsa *new, struct ospf_area *area)
/* Look through all interfaces, not just area, since interface
could be moved from one area to another. */
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
/* These are sanity check. */
if ((oi = getdata (node)) != NULL)
if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &new->data->id))
@@ -179,7 +180,7 @@ ospf_process_self_originated_lsa (struct ospf_lsa *new, struct ospf_area *area)
break;
case OSPF_SUMMARY_LSA:
case OSPF_ASBR_SUMMARY_LSA:
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
break;
case OSPF_AS_EXTERNAL_LSA :
#ifdef HAVE_NSSA
@@ -187,9 +188,9 @@ ospf_process_self_originated_lsa (struct ospf_lsa *new, struct ospf_area *area)
#endif /* HAVE_NSSA */
ei = ospf_external_info_check (new);
if (ei)
- ospf_external_lsa_refresh (new, ei, LSA_REFRESH_FORCE);
+ ospf_external_lsa_refresh (ospf, new, ei, LSA_REFRESH_FORCE);
else
- ospf_lsa_flush_as (new);
+ ospf_lsa_flush_as (ospf, new);
break;
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AREA_LSA:
@@ -229,8 +230,8 @@ ospf_process_self_originated_lsa (struct ospf_lsa *new, struct ospf_area *area)
ABRs calculate external routes from Type-5's and non-self Type-7s
*/
int
-ospf_flood (struct ospf_neighbor *nbr, struct ospf_lsa *current,
- struct ospf_lsa *new)
+ospf_flood (struct ospf *ospf, struct ospf_neighbor *nbr,
+ struct ospf_lsa *current, struct ospf_lsa *new)
{
struct ospf_interface *oi;
struct timeval now;
@@ -281,7 +282,7 @@ ospf_flood (struct ospf_neighbor *nbr, struct ospf_lsa *current,
DR and the LSA was received from a router other than the
Backup DR) the LSA will be flooded back out the receiving
interface. */
- lsa_ack_flag = ospf_flood_through (nbr, new);
+ lsa_ack_flag = ospf_flood_through (ospf, nbr, new);
#ifdef HAVE_OPAQUE_LSA
/* Remove the current database copy from all neighbors' Link state
@@ -302,17 +303,17 @@ ospf_flood (struct ospf_neighbor *nbr, struct ospf_lsa *current,
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
- ospf_ls_retransmit_delete_nbr_all (NULL, current);
+ ospf_ls_retransmit_delete_nbr_as (ospf, current);
break;
default:
- ospf_ls_retransmit_delete_nbr_all (nbr->oi->area, current);
+ ospf_ls_retransmit_delete_nbr_area (nbr->oi->area, current);
break;
}
}
/* Do some internal house keeping that is needed here */
SET_FLAG (new->flags, OSPF_LSA_RECEIVED);
- ospf_lsa_is_self_originated (new); /* Let it set the flag */
+ ospf_lsa_is_self_originated (ospf, new); /* Let it set the flag */
/* Install the new LSA in the link state database
(replacing the current database copy). This may cause the
@@ -321,15 +322,7 @@ ospf_flood (struct ospf_neighbor *nbr, struct ospf_lsa *current,
procedure cannot overwrite the newly installed LSA until
MinLSArrival seconds have elapsed. */
- new = ospf_lsa_install (nbr->oi, new);
-
-#ifdef HAVE_NSSA
- if (IS_DEBUG_OSPF_NSSA)
- zlog_info ("LSA[Flooding]: Type-%d installed", new->data->type);
-
- /* if (new->data->type == OSPF_AS_NSSA_LSA )
- return 0; */
-#endif /* HAVE_NSSA */
+ new = ospf_lsa_install (ospf, nbr->oi, new);
/* Acknowledge the receipt of the LSA by sending a Link State
Acknowledgment packet back out the receiving interface. */
@@ -340,11 +333,11 @@ ospf_flood (struct ospf_neighbor *nbr, struct ospf_lsa *current,
receiving router itself, the router must take special action,
either updating the LSA or in some cases flushing it from
the routing domain. */
- if (ospf_lsa_is_self_originated (new))
- ospf_process_self_originated_lsa (new, oi->area);
+ if (ospf_lsa_is_self_originated (ospf, new))
+ ospf_process_self_originated_lsa (ospf, new, oi->area);
else
/* Update statistics value for OSPF-MIB. */
- ospf_top->rx_lsa_count++;
+ ospf->rx_lsa_count++;
return 0;
}
@@ -355,6 +348,7 @@ ospf_flood_through_interface (struct ospf_interface *oi,
struct ospf_neighbor *inbr,
struct ospf_lsa *lsa)
{
+ struct ospf *ospf = oi->ospf;
struct ospf_neighbor *onbr;
struct route_node *rn;
int retx_flag;
@@ -440,7 +434,7 @@ ospf_flood_through_interface (struct ospf_interface *oi,
continue;
}
- if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf_top->opaque)
+ if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque)
&& IS_LSA_SELF (lsa)
&& onbr->state == NSM_Full)
{
@@ -579,8 +573,8 @@ ospf_flood_through_interface (struct ospf_interface *oi,
}
int
-ospf_flood_through_area (struct ospf_area * area,struct ospf_neighbor *inbr,
- struct ospf_lsa *lsa)
+ospf_flood_through_area (struct ospf_area *area,
+ struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
{
listnode node;
int lsa_ack_flag = 0;
@@ -618,7 +612,8 @@ ospf_flood_through_area (struct ospf_area * area,struct ospf_neighbor *inbr,
}
int
-ospf_flood_through_as (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
+ospf_flood_through_as (struct ospf *ospf, struct ospf_neighbor *inbr,
+ struct ospf_lsa *lsa)
{
listnode node;
int lsa_ack_flag;
@@ -642,7 +637,7 @@ ospf_flood_through_as (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
zlog_info ("Flood/AS: NSSA TRANSLATED LSA");
#endif /* HAVE_NSSA */
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
int continue_flag = 0;
struct ospf_area *area = getdata (node);
@@ -657,8 +652,8 @@ ospf_flood_through_as (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
case OSPF_AREA_NSSA: /* Sending Type 5 or 7 into NSSA area */
#ifdef HAVE_NSSA
/* Type-7, flood NSSA area */
- if (lsa->data->type == OSPF_AS_NSSA_LSA)
- /* We will send it. */
+ if (lsa->data->type == OSPF_AS_NSSA_LSA
+ && area == lsa->area)
continue_flag = 0;
else
continue_flag = 1; /* Skip this NSSA area for Type-5's et al */
@@ -703,7 +698,8 @@ ospf_flood_through_as (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
}
int
-ospf_flood_through (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
+ospf_flood_through (struct ospf *ospf,
+ struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
{
int lsa_ack_flag = 0;
@@ -732,7 +728,7 @@ ospf_flood_through (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
- lsa_ack_flag = ospf_flood_through_as (inbr, lsa);
+ lsa_ack_flag = ospf_flood_through_as (ospf, inbr, lsa);
break;
#ifdef HAVE_NSSA
/* Type-7 Only received within NSSA, then flooded */
@@ -766,7 +762,7 @@ ospf_flood_through (struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
- lsa_ack_flag = ospf_flood_through_as (inbr, lsa);
+ lsa_ack_flag = ospf_flood_through_as (ospf, inbr, lsa);
break;
#ifdef HAVE_NSSA
/* Type-7 Only received within NSSA, then flooded */
@@ -960,62 +956,44 @@ ospf_ls_retransmit_lookup (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
return ospf_lsdb_lookup (&nbr->ls_rxmt, lsa);
}
-/* Remove All neighbor/interface's Link State Retransmit list in area. */
void
-ospf_ls_retransmit_delete_nbr_all (struct ospf_area *area,
- struct ospf_lsa *lsa)
+ospf_ls_retransmit_delete_nbr_if (struct ospf_interface *oi,
+ struct ospf_lsa *lsa)
{
- listnode node;
- list oiflist = area ? area->oiflist : ospf_top->oiflist;
-
- for (node = listhead (oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
- struct route_node *rn;
- struct ospf_neighbor *nbr;
- struct ospf_lsa *lsr;
-
- if (ospf_if_is_enable (oi))
- for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- /* If LSA find in LS-retransmit list, then remove it. */
- if ((nbr = rn->info) != NULL)
- {
- lsr = ospf_ls_retransmit_lookup (nbr, lsa);
+ struct route_node *rn;
+ struct ospf_neighbor *nbr;
+ struct ospf_lsa *lsr;
+
+ if (ospf_if_is_enable (oi))
+ for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
+ /* If LSA find in LS-retransmit list, then remove it. */
+ if ((nbr = rn->info) != NULL)
+ {
+ lsr = ospf_ls_retransmit_lookup (nbr, lsa);
- /* If LSA find in ls-retransmit list, remove it. */
- if (lsr != NULL && lsr->data->ls_seqnum == lsa->data->ls_seqnum)
- ospf_ls_retransmit_delete (nbr, lsr);
- }
- }
+ /* If LSA find in ls-retransmit list, remove it. */
+ if (lsr != NULL && lsr->data->ls_seqnum == lsa->data->ls_seqnum)
+ ospf_ls_retransmit_delete (nbr, lsr);
+ }
}
-/* Add LSA to the current database copy of all neighbors'
- Link state retransmission lists. */
void
-ospf_ls_retransmit_add_nbr_all (struct ospf_interface *ospfi,
- struct ospf_lsa *lsa)
+ospf_ls_retransmit_delete_nbr_area (struct ospf_area *area,
+ struct ospf_lsa *lsa)
{
listnode node;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
- struct route_node *rn;
- struct ospf_neighbor *nbr;
- struct ospf_lsa *old;
+ for (node = listhead (area->oiflist); node; nextnode (node))
+ ospf_ls_retransmit_delete_nbr_if (getdata (node), lsa);
+}
- if (ospf_if_is_enable (oi))
- if (OSPF_AREA_SAME (&ospfi->area, &oi->area))
- for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info) != NULL)
- if (nbr->state == NSM_Full)
- {
- if ((old = ospf_ls_retransmit_lookup (nbr, lsa)))
- ospf_ls_retransmit_delete (nbr, old);
+void
+ospf_ls_retransmit_delete_nbr_as (struct ospf *ospf, struct ospf_lsa *lsa)
+{
+ listnode node;
- ospf_ls_retransmit_add (nbr, lsa);
- }
- }
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
+ ospf_ls_retransmit_delete_nbr_if (getdata (node), lsa);
}
@@ -1027,22 +1005,13 @@ ospf_lsa_flush_area (struct ospf_lsa *lsa, struct ospf_area *area)
{
lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
ospf_flood_through_area (area, NULL, lsa);
- ospf_lsa_maxage (lsa);
-}
-
-void
-ospf_lsa_flush_as (struct ospf_lsa *lsa)
-{
- lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
- ospf_flood_through_as (NULL, lsa);
- ospf_lsa_maxage (lsa);
+ ospf_lsa_maxage (area->ospf, lsa);
}
-/* Flush LSA through AS -- used for AS-external-LSAs. */
void
-ospf_flush_through_as (struct ospf_lsa *lsa)
+ospf_lsa_flush_as (struct ospf *ospf, struct ospf_lsa *lsa)
{
lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
- ospf_flood_through_as (NULL, lsa);
- ospf_lsa_maxage (lsa);
+ ospf_flood_through_as (ospf, NULL, lsa);
+ ospf_lsa_maxage (ospf, lsa);
}
diff --git a/ospfd/ospf_flood.h b/ospfd/ospf_flood.h
index 1a6ab979..2e3f0832 100644
--- a/ospfd/ospf_flood.h
+++ b/ospfd/ospf_flood.h
@@ -20,14 +20,17 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef _ZEBRA_OSPF_FLOODING_H
-#define _ZEBRA_OSPF_FLOODING_H
+#ifndef _ZEBRA_OSPF_FLOOD_H
+#define _ZEBRA_OSPF_FLOOD_H
-int ospf_flood (struct ospf_neighbor *, struct ospf_lsa *, struct ospf_lsa *);
-int ospf_flood_through (struct ospf_neighbor *, struct ospf_lsa *);
+int ospf_flood (struct ospf *, struct ospf_neighbor *, struct ospf_lsa *,
+ struct ospf_lsa *);
+int ospf_flood_through (struct ospf *, struct ospf_neighbor *,
+ struct ospf_lsa *);
int ospf_flood_through_area (struct ospf_area *, struct ospf_neighbor *,
struct ospf_lsa *);
-int ospf_flood_through_as (struct ospf_neighbor *, struct ospf_lsa *);
+int ospf_flood_through_as (struct ospf *, struct ospf_neighbor *,
+ struct ospf_lsa *);
unsigned long ospf_ls_request_count (struct ospf_neighbor *);
int ospf_ls_request_isempty (struct ospf_neighbor *);
@@ -47,19 +50,18 @@ void ospf_ls_retransmit_delete (struct ospf_neighbor *, struct ospf_lsa *);
void ospf_ls_retransmit_clear (struct ospf_neighbor *);
struct ospf_lsa *ospf_ls_retransmit_lookup (struct ospf_neighbor *,
struct ospf_lsa *);
-void ospf_ls_retransmit_delete_nbr_all (struct ospf_area *, struct ospf_lsa *);
+void ospf_ls_retransmit_delete_nbr_area (struct ospf_area *,
+ struct ospf_lsa *);
+void ospf_ls_retransmit_delete_nbr_as (struct ospf *, struct ospf_lsa *);
void ospf_ls_retransmit_add_nbr_all (struct ospf_interface *,
struct ospf_lsa *);
void ospf_flood_lsa_area (struct ospf_lsa *, struct ospf_area *);
void ospf_flood_lsa_as (struct ospf_lsa *);
void ospf_lsa_flush_area (struct ospf_lsa *, struct ospf_area *);
-void ospf_lsa_flush_as (struct ospf_lsa *);
-void ospf_flush_through_as (struct ospf_lsa *);
+void ospf_lsa_flush_as (struct ospf *, struct ospf_lsa *);
struct external_info *ospf_external_info_check (struct ospf_lsa *);
-void debug_ospf_ls_retransmit (struct ospf_neighbor *);
-
void ospf_lsdb_init (struct ospf_lsdb *);
-#endif /* _ZEBRA_OSPF_FLOODING_H */
+#endif /* _ZEBRA_OSPF_FLOOD_H */
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 32c8d86b..4dd90dc1 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -71,8 +71,9 @@ ospf_find_abr_route (struct route_table *rtrs,
}
void
-ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
- struct ospf_route *new_or, struct ospf_route *abr_or)
+ospf_ia_network_route (struct ospf *ospf, struct route_table *rt,
+ struct prefix_ipv4 *p, struct ospf_route *new_or,
+ struct ospf_route *abr_or)
{
struct route_node *rn1;
struct ospf_route *or;
@@ -94,7 +95,7 @@ ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
zlog_info ("ospf_ia_network_route(): "
"Found a route to the same network");
/* Check the existing route. */
- if ((res = ospf_route_cmp (new_or, or)) < 0)
+ if ((res = ospf_route_cmp (ospf, new_or, or)) < 0)
{
/* New route is better, so replace old one. */
ospf_route_subst (rn1, new_or, abr_or);
@@ -127,18 +128,19 @@ ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
}
void
-ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
+ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs,
+ struct prefix_ipv4 *p,
struct ospf_route *new_or, struct ospf_route *abr_or)
{
- struct route_node *rn;
struct ospf_route *or = NULL;
+ struct route_node *rn;
int ret;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_router_route(): considering %s/%d",
inet_ntoa (p->prefix), p->prefixlen);
/* Find a route to the same dest */
- rn = route_node_get (rt,(struct prefix *) p);
+ rn = route_node_get (rtrs, (struct prefix *) p);
if (rn->info == NULL)
/* This is a new route */
@@ -146,11 +148,11 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
else
{
struct ospf_area *or_area;
- or_area = ospf_area_lookup_by_area_id (new_or->u.std.area_id);
+ or_area = ospf_area_lookup_by_area_id (ospf, new_or->u.std.area_id);
assert (or_area);
/* This is an additional route */
route_unlock_node (rn);
- or = ospf_find_asbr_route_through_area (rt, p, or_area);
+ or = ospf_find_asbr_route_through_area (rtrs, p, or_area);
}
if (or)
@@ -159,7 +161,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
zlog_info ("ospf_ia_router_route(): "
"a route to the same ABR through the same area exists");
/* New route is better */
- if ((ret = ospf_route_cmp (new_or, or)) < 0)
+ if ((ret = ospf_route_cmp (ospf, new_or, or)) < 0)
{
listnode_delete (rn->info, or);
ospf_route_free (or);
@@ -194,28 +196,21 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
}
-struct ia_args
-{
- struct route_table *rt;
- struct route_table *rtrs;
- struct ospf_area *area;
-};
-
int
-process_summary_lsa (struct ospf_lsa *l, void *v, int i)
+process_summary_lsa (struct ospf_area *area, struct route_table *rt,
+ struct route_table *rtrs, struct ospf_lsa *lsa)
{
+ struct ospf *ospf = area->ospf;
struct ospf_area_range *range;
struct ospf_route *abr_or, *new_or;
struct summary_lsa *sl;
struct prefix_ipv4 p, abr;
u_int32_t metric;
- struct ia_args *args;
- if (l == NULL)
+ if (lsa == NULL)
return 0;
- args = (struct ia_args *) v;
- sl = (struct summary_lsa *) l->data;
+ sl = (struct summary_lsa *) lsa->data;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_summary_lsa(): LS ID: %s", inet_ntoa (sl->header.id));
@@ -225,10 +220,10 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
if (metric == OSPF_LS_INFINITY)
return 0;
- if (IS_LSA_MAXAGE (l))
+ if (IS_LSA_MAXAGE (lsa))
return 0;
- if (ospf_lsa_is_self_originated (l))
+ if (ospf_lsa_is_self_originated (area->ospf, lsa))
return 0;
p.family = AF_INET;
@@ -242,12 +237,12 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
apply_mask_ipv4 (&p);
if (sl->header.type == OSPF_SUMMARY_LSA &&
- (range = ospf_area_range_match_any (ospf_top, &p)) &&
+ (range = ospf_area_range_match_any (ospf, &p)) &&
ospf_area_range_active (range))
return 0;
- if (ospf_top->abr_type != OSPF_ABR_STAND &&
- args->area->external_routing != OSPF_AREA_DEFAULT &&
+ if (ospf->abr_type != OSPF_ABR_STAND &&
+ area->external_routing != OSPF_AREA_DEFAULT &&
p.prefix.s_addr == OSPF_DEFAULT_DESTINATION &&
p.prefixlen == 0)
return 0; /* Ignore summary default from a stub area */
@@ -257,7 +252,7 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
abr.prefixlen = IPV4_MAX_BITLEN;
apply_mask_ipv4 (&abr);
- abr_or = ospf_find_abr_route (args->rtrs, &abr, args->area);
+ abr_or = ospf_find_abr_route (rtrs, &abr, area);
if (abr_or == NULL)
return 0;
@@ -269,32 +264,35 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
new_or->u.std.options = sl->header.options;
new_or->u.std.origin = (struct lsa_header *) sl;
new_or->cost = abr_or->cost + metric;
- new_or->u.std.area_id = args->area->area_id;
+ new_or->u.std.area_id = area->area_id;
#ifdef HAVE_NSSA
- new_or->u.std.external_routing = args->area->external_routing;
+ new_or->u.std.external_routing = area->external_routing;
#endif /* HAVE_NSSA */
new_or->path_type = OSPF_PATH_INTER_AREA;
if (sl->header.type == OSPF_SUMMARY_LSA)
- ospf_ia_network_route (args->rt, &p, new_or, abr_or);
+ ospf_ia_network_route (ospf, rt, &p, new_or, abr_or);
else
{
new_or->type = OSPF_DESTINATION_ROUTER;
new_or->u.std.flags = ROUTER_LSA_EXTERNAL;
- ospf_ia_router_route (args->rtrs, &p, new_or, abr_or);
+ ospf_ia_router_route (ospf, rtrs, &p, new_or, abr_or);
}
return 0;
}
void
-ospf_examine_summaries (struct ospf_area * area,
+ospf_examine_summaries (struct ospf_area *area,
struct route_table *lsdb_rt,
struct route_table *rt,
struct route_table *rtrs)
{
- struct ia_args args = {rt, rtrs, area};
- foreach_lsa (lsdb_rt, &args, 0, process_summary_lsa);
+ struct ospf_lsa *lsa;
+ struct route_node *rn;
+
+ LSDB_LOOP (lsdb_rt, rn, lsa)
+ process_summary_lsa (area, rt, rtrs, lsa);
}
int
@@ -305,7 +303,8 @@ ospf_area_is_transit (struct ospf_area *area)
}
void
-ospf_update_network_route (struct route_table *rt,
+ospf_update_network_route (struct ospf *ospf,
+ struct route_table *rt,
struct route_table *rtrs,
struct summary_lsa *lsa,
struct prefix_ipv4 *p,
@@ -336,7 +335,7 @@ ospf_update_network_route (struct route_table *rt,
if (! rn)
{
- if (ospf_top->abr_type != OSPF_ABR_SHORTCUT)
+ if (ospf->abr_type != OSPF_ABR_SHORTCUT)
return; /* Standard ABR can update only already installed
backbone paths */
if (IS_DEBUG_OSPF_EVENT)
@@ -375,7 +374,7 @@ ospf_update_network_route (struct route_table *rt,
return;
}
- if (ospf_top->abr_type == OSPF_ABR_SHORTCUT)
+ if (ospf->abr_type == OSPF_ABR_SHORTCUT)
{
if (or->path_type == OSPF_PATH_INTRA_AREA &&
!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
@@ -420,7 +419,7 @@ ospf_update_network_route (struct route_table *rt,
ospf_route_subst_nexthops (or, abr_or->path);
or->cost = cost;
- if ((ospf_top->abr_type == OSPF_ABR_SHORTCUT) &&
+ if ((ospf->abr_type == OSPF_ABR_SHORTCUT) &&
!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
{
or->path_type = OSPF_PATH_INTER_AREA;
@@ -437,7 +436,8 @@ ospf_update_network_route (struct route_table *rt,
}
void
-ospf_update_router_route (struct route_table *rtrs,
+ospf_update_router_route (struct ospf *ospf,
+ struct route_table *rtrs,
struct summary_lsa *lsa,
struct prefix_ipv4 *p,
struct ospf_area *area)
@@ -465,17 +465,17 @@ ospf_update_router_route (struct route_table *rtrs,
/* First try to find a backbone path,
because standard ABR can update only BB-associated paths */
- if ((ospf_top->backbone == NULL) &&
- (ospf_top->abr_type != OSPF_ABR_SHORTCUT))
+ if ((ospf->backbone == NULL) &&
+ (ospf->abr_type != OSPF_ABR_SHORTCUT))
/* no BB area, not Shortcut ABR, exiting */
return;
- or = ospf_find_asbr_route_through_area (rtrs, p, ospf_top->backbone);
+ or = ospf_find_asbr_route_through_area (rtrs, p, ospf->backbone);
if (or == NULL)
{
- if (ospf_top->abr_type != OSPF_ABR_SHORTCUT)
+ if (ospf->abr_type != OSPF_ABR_SHORTCUT)
/* route to ASBR through the BB not found
the router is not Shortcut ABR, exiting */
@@ -500,7 +500,7 @@ ospf_update_router_route (struct route_table *rtrs,
#endif /* HAVE_NSSA */
new_or->path_type = OSPF_PATH_INTER_AREA;
new_or->u.std.flags = ROUTER_LSA_EXTERNAL;
- ospf_ia_router_route (rtrs, p, new_or, abr_or);
+ ospf_ia_router_route (ospf, rtrs, p, new_or, abr_or);
return;
}
@@ -537,22 +537,22 @@ ospf_update_router_route (struct route_table *rtrs,
}
int
-process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i)
+process_transit_summary_lsa (struct ospf_area *area, struct route_table *rt,
+ struct route_table *rtrs, struct ospf_lsa *lsa)
{
+ struct ospf *ospf = area->ospf;
struct summary_lsa *sl;
struct prefix_ipv4 p;
u_int32_t metric;
- struct ia_args *args;
- if (l == NULL)
+ if (lsa == NULL)
return 0;
- args = (struct ia_args *) v;
- sl = (struct summary_lsa *) l->data;
+ sl = (struct summary_lsa *) lsa->data;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): LS ID: %s",
- inet_ntoa (l->data->id));
+ inet_ntoa (lsa->data->id));
metric = GET_METRIC (sl->metric);
if (metric == OSPF_LS_INFINITY)
@@ -562,14 +562,14 @@ process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i)
return 0;
}
- if (IS_LSA_MAXAGE (l))
+ if (IS_LSA_MAXAGE (lsa))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): This LSA is too old");
return 0;
}
- if (ospf_lsa_is_self_originated (l))
+ if (ospf_lsa_is_self_originated (area->ospf, lsa))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): This LSA is mine, skip");
@@ -587,28 +587,29 @@ process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i)
apply_mask_ipv4 (&p);
if (sl->header.type == OSPF_SUMMARY_LSA)
- ospf_update_network_route (args->rt, args->rtrs, sl, &p, args->area);
+ ospf_update_network_route (ospf, rt, rtrs, sl, &p, area);
else
- ospf_update_router_route (args->rtrs, sl, &p, args->area);
+ ospf_update_router_route (ospf, rtrs, sl, &p, area);
return 0;
}
void
ospf_examine_transit_summaries (struct ospf_area *area,
- /* struct ospf_lsdb *lsdb, */
struct route_table *lsdb_rt,
struct route_table *rt,
struct route_table *rtrs)
{
- struct ia_args args = {rt, rtrs, area};
+ struct ospf_lsa *lsa;
+ struct route_node *rn;
- /* ospf_lsdb_iterator (lsdb, &args, 0, process_transit_summary_lsa); */
- foreach_lsa (lsdb_rt, &args, 0, process_transit_summary_lsa);
+ LSDB_LOOP (lsdb_rt, rn, lsa)
+ process_transit_summary_lsa (area, rt, rtrs, lsa);
}
void
-ospf_ia_routing (struct route_table *rt,
+ospf_ia_routing (struct ospf *ospf,
+ struct route_table *rt,
struct route_table *rtrs)
{
struct ospf_area * area;
@@ -621,13 +622,13 @@ ospf_ia_routing (struct route_table *rt,
listnode node;
struct ospf_area *area;
- switch (ospf_top->abr_type)
+ switch (ospf->abr_type)
{
case OSPF_ABR_STAND:
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Standard ABR");
- if ((area = ospf_top->backbone))
+ if ((area = ospf->backbone))
{
listnode node;
@@ -639,9 +640,9 @@ ospf_ia_routing (struct route_table *rt,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
- if (area != ospf_top->backbone)
+ if (area != ospf->backbone)
if (ospf_area_is_transit (area))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
@@ -653,10 +654,10 @@ ospf_ia_routing (struct route_table *rt,
case OSPF_ABR_CISCO:
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Alternative Cisco/IBM ABR");
- area = ospf_top->backbone; /* Find the BB */
+ area = ospf->backbone; /* Find the BB */
/* If we have an active BB connection */
- if (area && ospf_act_bb_connection ())
+ if (area && ospf_act_bb_connection (ospf))
{
if (IS_DEBUG_OSPF_EVENT)
{
@@ -666,9 +667,9 @@ ospf_ia_routing (struct route_table *rt,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
- if (area != ospf_top->backbone)
+ if (area != ospf->backbone)
if (ospf_area_is_transit (area))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
@@ -677,7 +678,7 @@ ospf_ia_routing (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing(): "
"Active BB connection not found");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
@@ -685,10 +686,10 @@ ospf_ia_routing (struct route_table *rt,
case OSPF_ABR_SHORTCUT:
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Alternative Shortcut");
- area = ospf_top->backbone; /* Find the BB */
+ area = ospf->backbone; /* Find the BB */
/* If we have an active BB connection */
- if (area && ospf_act_bb_connection ())
+ if (area && ospf_act_bb_connection (ospf))
{
if (IS_DEBUG_OSPF_EVENT)
{
@@ -698,12 +699,12 @@ ospf_ia_routing (struct route_table *rt,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
- if (area != ospf_top->backbone)
+ if (area != ospf->backbone)
if (ospf_area_is_transit (area) ||
((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
- ((ospf_top->backbone == NULL) ||
+ ((ospf->backbone == NULL) ||
((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
area->shortcut_capability))))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
@@ -719,7 +720,7 @@ ospf_ia_routing (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():not ABR, considering all areas");
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
diff --git a/ospfd/ospf_ia.h b/ospfd/ospf_ia.h
index afb2d4d5..4eb3c9d8 100644
--- a/ospfd/ospf_ia.h
+++ b/ospfd/ospf_ia.h
@@ -36,7 +36,8 @@
ospf_examine_transit_summaries ((A), ASBR_SUMMARY_LSDB ((A)), (N), (R)); \
}
-void ospf_ia_routing (struct route_table *, struct route_table *);
+void ospf_ia_routing (struct ospf *, struct route_table *,
+ struct route_table *);
int ospf_area_is_transit (struct ospf_area *);
#endif /* _ZEBRA_OSPF_IA_H */
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index ddae9800..6a4a4273 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -32,6 +32,7 @@
#include "stream.h"
#include "log.h"
+#include "ospfd/ospfd.h"
#include "ospfd/ospf_spf.h"
#include "ospfd/ospf_interface.h"
#include "ospfd/ospf_ism.h"
@@ -42,7 +43,6 @@
#include "ospfd/ospf_nsm.h"
#include "ospfd/ospf_packet.h"
#include "ospfd/ospf_abr.h"
-#include "ospfd/ospfd.h"
#include "ospfd/ospf_network.h"
#include "ospfd/ospf_dump.h"
#ifdef HAVE_SNMP
@@ -58,7 +58,7 @@ ospf_if_get_output_cost (struct ospf_interface *oi)
u_int32_t bw, refbw;
bw = oi->ifp->bandwidth ? oi->ifp->bandwidth : OSPF_DEFAULT_BANDWIDTH;
- refbw = ospf_top ? ospf_top->ref_bandwidth : OSPF_DEFAULT_REF_BANDWIDTH;
+ refbw = oi->ospf->ref_bandwidth;
/* A specifed ip ospf cost overrides a calculated one. */
if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), output_cost_cmd) ||
@@ -157,7 +157,7 @@ ospf_delete_from_if (struct interface *ifp, struct ospf_interface *oi)
}
struct ospf_interface *
-ospf_if_new (struct interface *ifp, struct prefix *p)
+ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p)
{
struct ospf_interface *oi;
@@ -169,7 +169,7 @@ ospf_if_new (struct interface *ifp, struct prefix *p)
oi->address = p;
ospf_add_to_if (ifp, oi);
- listnode_add (ospf_top->oiflist, oi);
+ listnode_add (ospf->oiflist, oi);
/* Clear self-originated network-LSA. */
oi->network_lsa_self = NULL;
@@ -190,7 +190,6 @@ ospf_if_new (struct interface *ifp, struct prefix *p)
/* Add pseudo neighbor. */
oi->nbr_self = ospf_nbr_new (oi);
oi->nbr_self->state = NSM_TwoWay;
- /* oi->nbr_self->router_id = ospf_top->router_id; */
oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
oi->nbr_self->options = OSPF_OPTION_E;
@@ -198,11 +197,13 @@ ospf_if_new (struct interface *ifp, struct prefix *p)
oi->t_ls_upd_event = NULL;
oi->t_ls_ack_direct = NULL;
+ oi->crypt_seqnum = time (NULL);
+
#ifdef HAVE_OPAQUE_LSA
ospf_opaque_type9_lsa_init (oi);
#endif /* HAVE_OPAQUE_LSA */
- oi->ospf = ospf_top;
+ oi->ospf = ospf;
return oi;
}
@@ -257,7 +258,22 @@ ospf_if_cleanup (struct ospf_interface *oi)
oi->nbr_self = ospf_nbr_new (oi);
oi->nbr_self->state = NSM_TwoWay;
oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
- oi->nbr_self->options = OSPF_OPTION_E;
+
+ switch (oi->area->external_routing)
+ {
+ case OSPF_AREA_DEFAULT:
+ SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ break;
+ case OSPF_AREA_STUB:
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ break;
+#ifdef HAVE_NSSA
+ case OSPF_AREA_NSSA:
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ break;
+#endif /* HAVE_NSSA */
+ }
ospf_lsa_unlock (oi->network_lsa_self);
oi->network_lsa_self = NULL;
@@ -289,7 +305,7 @@ ospf_if_free (struct ospf_interface *oi)
ospf_delete_from_if (oi->ifp, oi);
- listnode_delete (ospf_top->oiflist, oi);
+ listnode_delete (oi->ospf->oiflist, oi);
listnode_delete (oi->area->oiflist, oi);
memset (oi, 0, sizeof (*oi));
@@ -302,13 +318,13 @@ ospf_if_free (struct ospf_interface *oi)
* return it if yes.
*/
struct ospf_interface *
-ospf_if_is_configured (struct in_addr *address)
+ospf_if_is_configured (struct ospf *ospf, struct in_addr *address)
{
listnode node;
struct ospf_interface *oi;
struct prefix *addr;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (oi->type == OSPF_IFTYPE_POINTOPOINT)
@@ -330,12 +346,13 @@ ospf_if_is_up (struct ospf_interface *oi)
}
struct ospf_interface *
-ospf_if_lookup_by_local_addr (struct interface *ifp, struct in_addr address)
+ospf_if_lookup_by_local_addr (struct ospf *ospf,
+ struct interface *ifp, struct in_addr address)
{
listnode node;
struct ospf_interface *oi;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (ifp && oi->ifp != ifp)
@@ -349,34 +366,36 @@ ospf_if_lookup_by_local_addr (struct interface *ifp, struct in_addr address)
}
struct ospf_interface *
-ospf_if_lookup_by_prefix (struct prefix_ipv4 *p)
+ospf_if_lookup_by_prefix (struct ospf *ospf, struct prefix_ipv4 *p)
{
listnode node;
struct ospf_interface *oi;
struct prefix ptmp;
/* Check each Interface. */
- for (node = listhead (ospf_top->oiflist); node; nextnode (node)) {
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
- {
- if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
- prefix_copy (&ptmp, oi->connected->destination);
- ptmp.prefixlen = IPV4_MAX_BITLEN;
- }
- else
- prefix_copy (&ptmp, oi->address);
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
+ {
+ if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ {
+ if (oi->type == OSPF_IFTYPE_POINTOPOINT)
+ {
+ prefix_copy (&ptmp, oi->connected->destination);
+ ptmp.prefixlen = IPV4_MAX_BITLEN;
+ }
+ else
+ prefix_copy (&ptmp, oi->address);
- apply_mask (&ptmp);
- if (prefix_same (&ptmp, (struct prefix *) p))
- return oi;
- }
- }
+ apply_mask (&ptmp);
+ if (prefix_same (&ptmp, (struct prefix *) p))
+ return oi;
+ }
+ }
return NULL;
}
/* determine receiving interface by source of packet */
struct ospf_interface *
-ospf_if_lookup_recv_interface (struct in_addr src)
+ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src)
{
listnode node;
struct prefix_ipv4 addr;
@@ -388,7 +407,7 @@ ospf_if_lookup_recv_interface (struct in_addr src)
match = NULL;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
oi = getdata (node);
@@ -421,6 +440,8 @@ ospf_if_stream_set (struct ospf_interface *oi)
void
ospf_if_stream_unset (struct ospf_interface *oi)
{
+ struct ospf *ospf = oi->ospf;
+
if (oi->obuf)
{
ospf_fifo_free (oi->obuf);
@@ -428,13 +449,14 @@ ospf_if_stream_unset (struct ospf_interface *oi)
if (oi->on_write_q)
{
- listnode_delete (ospf_top->oi_write_q, oi);
- if (list_isempty(ospf_top->oi_write_q))
- OSPF_TIMER_OFF (ospf_top->t_write);
+ listnode_delete (ospf->oi_write_q, oi);
+ if (list_isempty(ospf->oi_write_q))
+ OSPF_TIMER_OFF (ospf->t_write);
oi->on_write_q = 0;
}
}
}
+
struct ospf_if_params *
ospf_new_if_params ()
@@ -644,7 +666,7 @@ ospf_if_up (struct ospf_interface *oi)
else
{
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
- ospf_if_add_allspfrouters (ospf_top, oi->address, oi->ifp->ifindex);
+ ospf_if_add_allspfrouters (oi->ospf, oi->address, oi->ifp->ifindex);
ospf_if_stream_set (oi);
OSPF_ISM_EVENT_SCHEDULE (oi, ISM_InterfaceUp);
}
@@ -662,7 +684,7 @@ ospf_if_down (struct ospf_interface *oi)
/* Shutdown packet reception and sending */
ospf_if_stream_unset (oi);
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
- ospf_if_drop_allspfrouters (ospf_top, oi->address, oi->ifp->ifindex);
+ ospf_if_drop_allspfrouters (oi->ospf, oi->address, oi->ifp->ifindex);
return 1;
@@ -695,7 +717,7 @@ ospf_vl_data_free (struct ospf_vl_data *vl_data)
u_int vlink_count = 0;
struct ospf_interface *
-ospf_vl_new (struct ospf_vl_data *vl_data)
+ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
{
struct ospf_interface * voi;
struct interface * vi;
@@ -730,7 +752,7 @@ ospf_vl_new (struct ospf_vl_data *vl_data)
co->address = (struct prefix *)p;
- voi = ospf_if_new (vi, co->address);
+ voi = ospf_if_new (ospf, vi, co->address);
if (voi == NULL)
{
if (IS_DEBUG_OSPF_EVENT)
@@ -750,7 +772,7 @@ ospf_vl_new (struct ospf_vl_data *vl_data)
zlog_info ("ospf_vl_new(): set if->name to %s", vi->name);
area_id.s_addr = 0;
- area = ospf_area_get (area_id, OSPF_AREA_ID_FORMAT_ADDRESS);
+ area = ospf_area_get (ospf, area_id, OSPF_AREA_ID_FORMAT_ADDRESS);
voi->area = area;
if (IS_DEBUG_OSPF_EVENT)
@@ -782,7 +804,7 @@ ospf_vl_lookup (struct ospf_area *area, struct in_addr vl_peer)
struct ospf_vl_data *vl_data;
listnode node;
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (area->ospf->vlinks); node; nextnode (node))
if ((vl_data = getdata (node)) != NULL)
if (vl_data->vl_peer.s_addr == vl_peer.s_addr &&
IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
@@ -808,16 +830,16 @@ ospf_vl_shutdown (struct ospf_vl_data *vl_data)
}
void
-ospf_vl_add (struct ospf_vl_data *vl_data)
+ospf_vl_add (struct ospf *ospf, struct ospf_vl_data *vl_data)
{
- listnode_add (ospf_top->vlinks, vl_data);
+ listnode_add (ospf->vlinks, vl_data);
#ifdef HAVE_SNMP
ospf_snmp_vl_add (vl_data);
#endif /* HAVE_SNMP */
}
void
-ospf_vl_delete (struct ospf_vl_data *vl_data)
+ospf_vl_delete (struct ospf *ospf, struct ospf_vl_data *vl_data)
{
ospf_vl_shutdown (vl_data);
ospf_vl_if_delete (vl_data);
@@ -825,7 +847,7 @@ ospf_vl_delete (struct ospf_vl_data *vl_data)
#ifdef HAVE_SNMP
ospf_snmp_vl_delete (vl_data);
#endif /* HAVE_SNMP */
- listnode_delete (ospf_top->vlinks, vl_data);
+ listnode_delete (ospf->vlinks, vl_data);
ospf_vl_data_free (vl_data);
}
@@ -881,9 +903,10 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
void
-ospf_vl_up_check (struct ospf_area * area, struct in_addr rid,
+ospf_vl_up_check (struct ospf_area *area, struct in_addr rid,
struct vertex *v)
{
+ struct ospf *ospf = area->ospf;
listnode node;
struct ospf_vl_data *vl_data;
struct ospf_interface *oi;
@@ -895,7 +918,7 @@ ospf_vl_up_check (struct ospf_area * area, struct in_addr rid,
zlog_info ("ospf_vl_up_check(): Area is %s", inet_ntoa (area->area_id));
}
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (ospf->vlinks); node; nextnode (node))
{
if ((vl_data = getdata (node)) == NULL)
continue;
@@ -932,23 +955,23 @@ ospf_vl_up_check (struct ospf_area * area, struct in_addr rid,
}
void
-ospf_vl_unapprove ()
+ospf_vl_unapprove (struct ospf *ospf)
{
listnode node;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (ospf->vlinks); node; nextnode (node))
if ((vl_data = getdata (node)) != NULL)
UNSET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED);
}
void
-ospf_vl_shut_unapproved ()
+ospf_vl_shut_unapproved (struct ospf *ospf)
{
listnode node;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (ospf->vlinks); node; nextnode (node))
if ((vl_data = getdata (node)) != NULL)
if (!CHECK_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED))
ospf_vl_shutdown (vl_data);
@@ -974,7 +997,7 @@ ospf_vls_in_area (struct ospf_area *area)
struct ospf_vl_data *vl_data;
int c = 0;
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (area->ospf->vlinks); node; nextnode (node))
if ((vl_data = getdata (node)) != NULL)
if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
c++;
diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h
index 6dc01aea..1dc0ce74 100644
--- a/ospfd/ospf_interface.h
+++ b/ospfd/ospf_interface.h
@@ -190,12 +190,13 @@ struct ospf_interface
u_int32_t discarded; /* discarded input count by error. */
u_int32_t state_change; /* Number of status change. */
- u_int full_nbrs;
+ u_int32_t full_nbrs;
};
/* Prototypes. */
char *ospf_if_name (struct ospf_interface *);
-struct ospf_interface *ospf_if_new ();
+struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
+ struct prefix *);
void ospf_if_cleanup (struct ospf_interface *);
void ospf_if_free (struct ospf_interface *);
int ospf_if_up (struct ospf_interface *);
@@ -203,13 +204,17 @@ int ospf_if_down (struct ospf_interface *);
int ospf_if_is_up (struct ospf_interface *);
struct ospf_interface *ospf_if_lookup_by_name (char *);
-struct ospf_interface *ospf_if_lookup_by_local_addr (struct interface *, struct in_addr);
-struct ospf_interface *ospf_if_lookup_by_prefix (struct prefix_ipv4 *);
-struct ospf_interface *ospf_if_addr_local (struct in_addr src);
-struct ospf_interface *ospf_if_lookup_recv_interface (struct in_addr src);
-struct ospf_interface *ospf_if_is_configured (struct in_addr *);
-
-struct ospf_if_params *ospf_lookup_if_params (struct interface *, struct in_addr);
+struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
+ struct interface *,
+ struct in_addr);
+struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
+ struct prefix_ipv4 *);
+struct ospf_interface *ospf_if_addr_local (struct in_addr);
+struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *, struct in_addr);
+struct ospf_interface *ospf_if_is_configured (struct ospf *, struct in_addr *);
+
+struct ospf_if_params *ospf_lookup_if_params (struct interface *,
+ struct in_addr);
struct ospf_if_params *ospf_get_if_params (struct interface *, struct in_addr);
void ospf_del_if_params (struct ospf_if_params *);
void ospf_free_if_params (struct interface *, struct in_addr);
@@ -224,22 +229,21 @@ int ospf_if_is_enable (struct ospf_interface *);
int ospf_if_get_output_cost (struct ospf_interface *);
void ospf_if_recalculate_output_cost (struct interface *);
-struct ospf_interface *ospf_vl_new (struct ospf_vl_data *);
+struct ospf_interface *ospf_vl_new (struct ospf *, struct ospf_vl_data *);
struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *, struct in_addr);
struct ospf_vl_data *ospf_vl_lookup (struct ospf_area *, struct in_addr);
void ospf_vl_data_free (struct ospf_vl_data *);
-void ospf_vl_add (struct ospf_vl_data *);
-void ospf_vl_delete (struct ospf_vl_data *);
+void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
+void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
void ospf_vl_up_check (struct ospf_area *, struct in_addr, struct vertex *);
-void ospf_vl_unapprove ();
-void ospf_vl_shut_unapproved ();
+void ospf_vl_unapprove (struct ospf *);
+void ospf_vl_shut_unapproved (struct ospf *);
int ospf_full_virtual_nbrs (struct ospf_area *);
int ospf_vls_in_area (struct ospf_area *);
struct crypt_key *ospf_crypt_key_lookup (list, u_char);
struct crypt_key *ospf_crypt_key_new ();
void ospf_crypt_key_add (list, struct crypt_key *);
-int ospf_crypt_key_delete (list, u_char key_id);
-
+int ospf_crypt_key_delete (list, u_char);
#endif /* _ZEBRA_OSPF_INTERFACE_H */
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 56c1e990..7d91e63a 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -253,6 +253,15 @@ ospf_lsa_dup (struct ospf_lsa *lsa)
new->retransmit_counter = 0;
new->data = ospf_lsa_data_dup (lsa->data);
+ /* kevinm: Clear the refresh_list, otherwise there are going
+ to be problems when we try to remove the LSA from the
+ queue (which it's not a member of.)
+ XXX: Should we add the LSA to the refresh_list queue? */
+ new->refresh_list = -1;
+
+ if (IS_DEBUG_OSPF (lsa, LSA))
+ zlog_info ("LSA: duplicated %p (new: %p)", lsa, new);
+
return new;
}
@@ -385,7 +394,7 @@ lsa_seqnum_increment (struct ospf_lsa *lsa)
void
lsa_header_set (struct stream *s, u_char options,
- u_char type, struct in_addr id)
+ u_char type, struct in_addr id, struct in_addr router_id)
{
struct lsa_header *lsah;
@@ -395,12 +404,13 @@ lsa_header_set (struct stream *s, u_char options,
lsah->options = options;
lsah->type = type;
lsah->id = id;
- lsah->adv_router = ospf_top->router_id;
+ lsah->adv_router = router_id;
lsah->ls_seqnum = htonl (OSPF_INITIAL_SEQUENCE_NUMBER);
ospf_output_forward (s, OSPF_LSA_HEADER_SIZE);
}
+
/* router-LSA related functions. */
/* Get router-LSA flags. */
u_char
@@ -408,7 +418,7 @@ router_lsa_flags (struct ospf_area *area)
{
u_char flags;
- flags = ospf_top->flags;
+ flags = area->ospf->flags;
/* Set virtual link flag. */
if (ospf_full_virtual_nbrs (area))
@@ -419,10 +429,10 @@ router_lsa_flags (struct ospf_area *area)
/* Set Shortcut ABR behabiour flag. */
UNSET_FLAG (flags, ROUTER_LSA_SHORTCUT);
- if (ospf_top->abr_type == OSPF_ABR_SHORTCUT)
+ if (area->ospf->abr_type == OSPF_ABR_SHORTCUT)
if (!OSPF_IS_AREA_BACKBONE (area))
if ((area->shortcut_configured == OSPF_SHORTCUT_DEFAULT &&
- !ospf_top->backbone) ||
+ area->ospf->backbone == NULL) ||
area->shortcut_configured == OSPF_SHORTCUT_ENABLE)
SET_FLAG (flags, ROUTER_LSA_SHORTCUT);
@@ -437,21 +447,23 @@ router_lsa_flags (struct ospf_area *area)
And check neighbor count,
Point-to-Point link must have only 1 neighbor. */
struct ospf_neighbor *
-ospf_nbr_lookup_ptop (struct route_table *nbrs, struct in_addr router_id)
+ospf_nbr_lookup_ptop (struct ospf_interface *oi)
{
- struct route_node *rn;
struct ospf_neighbor *nbr = NULL;
+ struct route_node *rn;
/* Search neighbor, there must be one of two nbrs. */
- for (rn = route_top (nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info) != NULL)
- /* Ignore myself. */
- if (!IPV4_ADDR_SAME (&nbr->router_id, &ospf_top->router_id))
+ for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
+ if ((nbr = rn->info))
+ if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id))
if (nbr->state == NSM_Full)
- break;
+ {
+ route_unlock_node (rn);
+ break;
+ }
/* PtoP link must have only 1 neighbor. */
- if (ospf_nbr_count (nbrs, 0) > 1)
+ if (ospf_nbr_count (oi, 0) > 1)
zlog_warn ("Point-to-Point link has more than 1 neighobrs.");
return nbr;
@@ -481,7 +493,7 @@ lsa_link_ptop_set (struct stream *s, struct ospf_interface *oi)
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_info ("LSA[Type1]: Set link Point-to-Point");
- if ((nbr = ospf_nbr_lookup_ptop (oi->nbrs, ospf_top->router_id)))
+ if ((nbr = ospf_nbr_lookup_ptop (oi)))
if (nbr->state == NSM_Full)
{
/* For unnumbered point-to-point networks, the Link Data field
@@ -536,7 +548,7 @@ lsa_link_broadcast_set (struct stream *s, struct ospf_interface *oi)
/* Describe Type 2 link. */
if (dr && (dr->state == NSM_Full ||
IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))) &&
- ospf_nbr_count (oi->nbrs, NSM_Full) > 0)
+ ospf_nbr_count (oi, NSM_Full) > 0)
{
link_info_set (s, DR (oi), oi->address->u.prefix4,
LSA_LINK_TYPE_TRANSIT, 0, oi->output_cost);
@@ -572,11 +584,8 @@ lsa_link_virtuallink_set (struct stream *s, struct ospf_interface *oi)
{
struct ospf_neighbor *nbr;
- if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
- zlog_info ("LSA[Type1]: Set link type VL, state %d", oi->state);
-
if (oi->state == ISM_PointToPoint)
- if ((nbr = ospf_nbr_lookup_ptop (oi->nbrs, ospf_top->router_id)))
+ if ((nbr = ospf_nbr_lookup_ptop (oi)))
if (nbr->state == NSM_Full)
{
link_info_set (s, nbr->router_id, oi->address->u.prefix4,
@@ -589,6 +598,43 @@ lsa_link_virtuallink_set (struct stream *s, struct ospf_interface *oi)
#define lsa_link_nbma_set(S,O) lsa_link_broadcast_set (S, O)
+/* this function add for support point-to-multipoint ,see rfc2328
+12.4.1.4.*/
+/* from "edward rrr" <edward_rrr@hotmail.com>
+ http://marc.theaimsgroup.com/?l=zebra&m=100739222210507&w=2 */
+int
+lsa_link_ptomp_set (struct stream *s, struct ospf_interface *oi)
+{
+ int links = 0;
+ struct route_node *rn;
+ struct ospf_neighbor *nbr = NULL;
+ struct in_addr id, mask;
+
+ mask.s_addr = 0xffffffff;
+ id.s_addr = oi->address->u.prefix4.s_addr;
+ link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0, 0);
+ links++;
+
+ zlog_info ("PointToMultipoint: running ptomultip_set");
+
+ /* Search neighbor, */
+ for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
+ if ((nbr = rn->info) != NULL)
+ /* Ignore myself. */
+ if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id))
+ if (nbr->state == NSM_Full)
+
+ {
+ link_info_set (s, nbr->router_id, oi->address->u.prefix4,
+ LSA_LINK_TYPE_POINTOPOINT, 0, oi->output_cost);
+ links++;
+ zlog_info ("PointToMultipoint: set link to %s",
+ inet_ntoa(oi->address->u.prefix4));
+ }
+
+ return links;
+}
+
/* Set router-LSA link information. */
int
router_lsa_link_set (struct stream *s, struct ospf_area *area)
@@ -619,7 +665,7 @@ router_lsa_link_set (struct stream *s, struct ospf_area *area)
links += lsa_link_nbma_set (s, oi);
break;
case OSPF_IFTYPE_POINTOMULTIPOINT:
- /* Not supproted yet. */
+ links += lsa_link_ptomp_set (s, oi);
break;
case OSPF_IFTYPE_VIRTUALLINK:
links += lsa_link_virtuallink_set (s, oi);
@@ -664,6 +710,7 @@ ospf_router_lsa_body_set (struct stream *s, struct ospf_area *area)
struct ospf_lsa *
ospf_router_lsa_new (struct ospf_area *area)
{
+ struct ospf *ospf = area->ospf;
struct stream *s;
struct lsa_header *lsah;
struct ospf_lsa *new;
@@ -679,11 +726,11 @@ ospf_router_lsa_new (struct ospf_area *area)
#ifdef HAVE_NSSA
/* Set LSA common header fields. */
lsa_header_set (s, LSA_OPTIONS_GET (area) | LSA_NSSA_GET (area),
- OSPF_ROUTER_LSA, ospf_top->router_id);
+ OSPF_ROUTER_LSA, ospf->router_id, ospf->router_id);
#else /* ! HAVE_NSSA */
/* Set LSA common header fields. */
lsa_header_set (s, LSA_OPTIONS_GET (area),
- OSPF_ROUTER_LSA, ospf_top->router_id);
+ OSPF_ROUTER_LSA, ospf->router_id, ospf->router_id);
#endif /* HAVE_NSSA */
/* Set router-LSA body fields. */
@@ -725,10 +772,10 @@ ospf_router_lsa_originate (struct ospf_area *area)
}
/* Install LSA to LSDB. */
- new = ospf_lsa_install (NULL, new);
+ new = ospf_lsa_install (area->ospf, NULL, new);
/* Update LSA origination count. */
- ospf_top->lsa_originate_count++;
+ area->ospf->lsa_originate_count++;
/* Flooding new LSA through area. */
ospf_flood_through_area (area, NULL, new);
@@ -754,13 +801,13 @@ ospf_router_lsa_refresh (struct ospf_lsa *lsa)
assert (lsa->data);
/* Delete LSA from neighbor retransmit-list. */
- ospf_ls_retransmit_delete_nbr_all (area, lsa);
+ ospf_ls_retransmit_delete_nbr_area (area, lsa);
/* Create new router-LSA instance. */
new = ospf_router_lsa_new (area);
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
- ospf_lsa_install (NULL, new);
+ ospf_lsa_install (area->ospf, NULL, new);
/* Flood LSA through area. */
ospf_flood_through_area (area, NULL, new);
@@ -830,16 +877,17 @@ ospf_router_lsa_timer_add (struct ospf_area *area)
}
int
-ospf_router_lsa_update_timer (struct thread *t)
+ospf_router_lsa_update_timer (struct thread *thread)
{
+ struct ospf *ospf = THREAD_ARG (thread);
listnode node;
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_info ("Timer[router-LSA Update]: (timer expire)");
- ospf_top->t_router_lsa_update = NULL;
+ ospf->t_router_lsa_update = NULL;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = getdata (node);
struct ospf_lsa *lsa = area->router_lsa_self;
@@ -859,7 +907,7 @@ ospf_router_lsa_update_timer (struct thread *t)
}
/* If router-ID is changed, Link ID must change.
First flush old LSA, then originate new. */
- else if (!IPV4_ADDR_SAME (&lsa->data->id, &ospf_top->router_id))
+ else if (!IPV4_ADDR_SAME (&lsa->data->id, &ospf->router_id))
{
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_info("LSA[Type%d:%s]: Refresh router-LSA for Area %s",
@@ -875,7 +923,7 @@ ospf_router_lsa_update_timer (struct thread *t)
{
rl = (struct router_lsa *) lsa->data;
/* Refresh router-LSA, (not install) and flood through area. */
- if (rl->flags != ospf_top->flags)
+ if (rl->flags != ospf->flags)
ospf_router_lsa_timer_add (area);
}
}
@@ -928,7 +976,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
lsah = (struct lsa_header *) STREAM_DATA (s);
lsa_header_set (s, (OPTIONS (oi) | LSA_OPTIONS_GET (oi->area)),
- OSPF_NETWORK_LSA, DR (oi));
+ OSPF_NETWORK_LSA, DR (oi), oi->ospf->router_id);
/* Set network-LSA body fields. */
ospf_network_lsa_body_set (s, oi);
@@ -962,10 +1010,10 @@ ospf_network_lsa_originate (struct ospf_interface *oi)
return NULL;
/* Install LSA to LSDB. */
- new = ospf_lsa_install (oi, new);
+ new = ospf_lsa_install (oi->ospf, oi, new);
/* Update LSA origination count. */
- ospf_top->lsa_originate_count++;
+ oi->ospf->lsa_originate_count++;
/* Flooding new LSA through area. */
ospf_flood_through_area (oi->area, NULL, new);
@@ -989,7 +1037,7 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa, struct ospf_interface *oi)
assert (lsa->data);
/* Delete LSA from neighbor retransmit-list. */
- ospf_ls_retransmit_delete_nbr_all (area, lsa);
+ ospf_ls_retransmit_delete_nbr_area (area, lsa);
/* Create new network-LSA instance. */
new = ospf_network_lsa_new (oi);
@@ -997,7 +1045,7 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa, struct ospf_interface *oi)
return -1;
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
- ospf_lsa_install (oi, new);
+ ospf_lsa_install (area->ospf, oi, new);
/* Flood LSA through aera. */
ospf_flood_through_area (area, NULL, new);
@@ -1112,7 +1160,8 @@ ospf_summary_lsa_new (struct ospf_area *area, struct prefix *p,
s = stream_new (OSPF_MAX_LSA_SIZE);
lsah = (struct lsa_header *) STREAM_DATA (s);
- lsa_header_set (s, LSA_OPTIONS_GET (area), OSPF_SUMMARY_LSA, id);
+ lsa_header_set (s, LSA_OPTIONS_GET (area), OSPF_SUMMARY_LSA,
+ id, area->ospf->router_id);
/* Set summary-LSA body fields. */
ospf_summary_lsa_body_set (s, p, metric);
@@ -1142,16 +1191,16 @@ ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
struct ospf_lsa *new;
struct in_addr id;
- id = ospf_lsa_unique_id (area->lsdb, OSPF_SUMMARY_LSA, p);
+ id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_SUMMARY_LSA, p);
/* Create new summary-LSA instance. */
new = ospf_summary_lsa_new (area, (struct prefix *) p, metric, id);
/* Instlal LSA to LSDB. */
- new = ospf_lsa_install (NULL, new);
+ new = ospf_lsa_install (area->ospf, NULL, new);
/* Update LSA origination count. */
- ospf_top->lsa_originate_count++;
+ area->ospf->lsa_originate_count++;
/* Flooding new LSA through area. */
ospf_flood_through_area (area, NULL, new);
@@ -1167,7 +1216,7 @@ ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
}
struct ospf_lsa*
-ospf_summary_lsa_refresh (struct ospf_lsa *lsa)
+ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{
struct ospf_lsa *new;
struct summary_lsa *sl;
@@ -1186,7 +1235,7 @@ ospf_summary_lsa_refresh (struct ospf_lsa *lsa)
/* Re-calculate checksum. */
ospf_lsa_checksum (new->data);
- ospf_lsa_install (NULL, new);
+ ospf_lsa_install (ospf, NULL, new);
/* Flood LSA through AS. */
ospf_flood_through_area (new->area, NULL, new);
@@ -1238,7 +1287,8 @@ ospf_summary_asbr_lsa_new (struct ospf_area *area, struct prefix *p,
s = stream_new (OSPF_MAX_LSA_SIZE);
lsah = (struct lsa_header *) STREAM_DATA (s);
- lsa_header_set (s, LSA_OPTIONS_GET (area), OSPF_ASBR_SUMMARY_LSA, id);
+ lsa_header_set (s, LSA_OPTIONS_GET (area), OSPF_ASBR_SUMMARY_LSA,
+ id, area->ospf->router_id);
/* Set summary-LSA body fields. */
ospf_summary_asbr_lsa_body_set (s, p, metric);
@@ -1268,16 +1318,16 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
struct ospf_lsa *new;
struct in_addr id;
- id = ospf_lsa_unique_id (area->lsdb, OSPF_ASBR_SUMMARY_LSA, p);
+ id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_ASBR_SUMMARY_LSA, p);
/* Create new summary-LSA instance. */
new = ospf_summary_asbr_lsa_new (area, (struct prefix *) p, metric, id);
/* Install LSA to LSDB. */
- new = ospf_lsa_install (NULL, new);
+ new = ospf_lsa_install (area->ospf, NULL, new);
/* Update LSA origination count. */
- ospf_top->lsa_originate_count++;
+ area->ospf->lsa_originate_count++;
/* Flooding new LSA through area. */
ospf_flood_through_area (area, NULL, new);
@@ -1293,7 +1343,7 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
}
struct ospf_lsa*
-ospf_summary_asbr_lsa_refresh (struct ospf_lsa *lsa)
+ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{
struct ospf_lsa *new;
struct summary_lsa *sl;
@@ -1312,7 +1362,7 @@ ospf_summary_asbr_lsa_refresh (struct ospf_lsa *lsa)
/* Re-calculate checksum. */
ospf_lsa_checksum (new->data);
- ospf_lsa_install (NULL, new);
+ ospf_lsa_install (ospf, NULL, new);
/* Flood LSA through area. */
ospf_flood_through_area (new->area, NULL, new);
@@ -1332,11 +1382,10 @@ ospf_summary_asbr_lsa_refresh (struct ospf_lsa *lsa)
/* Get nexthop for AS-external-LSAs. Return nexthop if its interface
is connected, else 0*/
struct in_addr
-ospf_external_lsa_nexthop_get (struct in_addr nexthop)
+ospf_external_lsa_nexthop_get (struct ospf *ospf, struct in_addr nexthop)
{
struct in_addr fwd;
struct prefix nh;
- /* struct route_node *rn; */
listnode n1;
fwd.s_addr = 0;
@@ -1349,7 +1398,7 @@ ospf_external_lsa_nexthop_get (struct in_addr nexthop)
nh.u.prefix4 = nexthop;
nh.prefixlen = IPV4_MAX_BITLEN;
- for (n1 = listhead (ospf_top->oiflist); n1; nextnode (n1))
+ for (n1 = listhead (ospf->oiflist); n1; nextnode (n1))
{
struct ospf_interface *oi = getdata (n1);
@@ -1382,24 +1431,33 @@ ospf_get_ip_from_ifp (struct ospf_interface *oi)
/* Get 1st IP connection for Forward Addr */
struct in_addr
-ospf_get_nssa_ip (void)
+ospf_get_nssa_ip (struct ospf_area *area)
{
struct in_addr fwd;
+ struct in_addr best_default;
listnode n1;
fwd.s_addr = 0;
+ best_default.s_addr = 0;
-
- for (n1 = listhead (ospf_top->oiflist); n1; nextnode (n1))
+ for (n1 = listhead (area->ospf->oiflist); n1; nextnode (n1))
{
struct ospf_interface *oi = getdata (n1);
if (if_is_up (oi->ifp))
if (oi->area->external_routing == OSPF_AREA_NSSA)
if (oi->address && oi->address->family == AF_INET)
- return (oi->address->u.prefix4 );
+ {
+ if (best_default.s_addr == 0)
+ best_default = oi->address->u.prefix4;
+ if (oi->area == area)
+ return oi->address->u.prefix4;
+ }
}
+ if (best_default.s_addr != 0)
+ return best_default;
+
return fwd;
}
#endif /* HAVE_NSSA */
@@ -1411,36 +1469,37 @@ ospf_get_nssa_ip (void)
#define DEFAULT_METRIC_TYPE EXTERNAL_METRIC_TYPE_2
int
-metric_type (u_char src)
+metric_type (struct ospf *ospf, u_char src)
{
- return (ospf_top->dmetric[src].type < 0 ?
- DEFAULT_METRIC_TYPE : ospf_top->dmetric[src].type);
+ return (ospf->dmetric[src].type < 0 ?
+ DEFAULT_METRIC_TYPE : ospf->dmetric[src].type);
}
int
-metric_value (u_char src)
+metric_value (struct ospf *ospf, u_char src)
{
- if (ospf_top->dmetric[src].value < 0)
+ if (ospf->dmetric[src].value < 0)
{
if (src == DEFAULT_ROUTE)
{
- if (ospf_top->default_originate == DEFAULT_ORIGINATE_ZEBRA)
+ if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
return DEFAULT_DEFAULT_ORIGINATE_METRIC;
else
return DEFAULT_DEFAULT_ALWAYS_METRIC;
}
- else if (ospf_top->default_metric < 0)
+ else if (ospf->default_metric < 0)
return DEFAULT_DEFAULT_METRIC;
else
- return ospf_top->default_metric;
+ return ospf->default_metric;
}
- return ospf_top->dmetric[src].value;
+ return ospf->dmetric[src].value;
}
/* Set AS-external-LSA body. */
void
-ospf_external_lsa_body_set (struct stream *s, struct external_info *ei)
+ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
+ struct ospf *ospf)
{
struct prefix_ipv4 *p = &ei->p;
struct in_addr mask, fwd_addr;
@@ -1456,10 +1515,10 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei)
type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ?
- ROUTEMAP_METRIC_TYPE (ei) : metric_type (type);
+ ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type);
mvalue = (ROUTEMAP_METRIC (ei) != -1) ?
- ROUTEMAP_METRIC (ei) : metric_value (type);
+ ROUTEMAP_METRIC (ei) : metric_value (ospf, type);
/* Put type of external metric. */
stream_putc (s, (mtype == EXTERNAL_METRIC_TYPE_2 ? 0x80 : 0));
@@ -1468,7 +1527,7 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei)
stream_put_ospf_metric (s, mvalue);
/* Get forwarding address to nexthop if on the Connection List, else 0. */
- fwd_addr = ospf_external_lsa_nexthop_get (ei->nexthop);
+ fwd_addr = ospf_external_lsa_nexthop_get (ospf, ei->nexthop);
/* Put forwarding address. */
stream_put_ipv4 (s, fwd_addr.s_addr);
@@ -1479,7 +1538,8 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei)
/* Create new external-LSA. */
struct ospf_lsa *
-ospf_external_lsa_new (struct external_info *ei, struct in_addr *old_id)
+ospf_external_lsa_new (struct ospf *ospf,
+ struct external_info *ei, struct in_addr *old_id)
{
struct stream *s;
struct lsa_header *lsah;
@@ -1503,7 +1563,7 @@ ospf_external_lsa_new (struct external_info *ei, struct in_addr *old_id)
/* Get Link State with unique ID. */
else
{
- id = ospf_lsa_unique_id (ospf_top->lsdb, OSPF_AS_EXTERNAL_LSA, &ei->p);
+ id = ospf_lsa_unique_id (ospf, ospf->lsdb, OSPF_AS_EXTERNAL_LSA, &ei->p);
if (id.s_addr == 0xffffffff)
{
/* Maybe Link State ID not available. */
@@ -1518,10 +1578,11 @@ ospf_external_lsa_new (struct external_info *ei, struct in_addr *old_id)
lsah = (struct lsa_header *) STREAM_DATA (s);
/* Set LSA common header fields. */
- lsa_header_set (s, OSPF_OPTION_E, OSPF_AS_EXTERNAL_LSA, id);
+ lsa_header_set (s, OSPF_OPTION_E, OSPF_AS_EXTERNAL_LSA,
+ id, ospf->router_id);
/* Set AS-external-LSA body fields. */
- ospf_external_lsa_body_set (s, ei);
+ ospf_external_lsa_body_set (s, ei, ospf);
/* Set length. */
length = stream_get_endp (s);
@@ -1541,56 +1602,14 @@ ospf_external_lsa_new (struct external_info *ei, struct in_addr *old_id)
}
#ifdef HAVE_NSSA
-/* Set AS-external-LSA body test. */
-void
-ospf_external_lsa_body_test (struct stream *s)
-{
- struct in_addr mask, fwd_addr;
- u_int32_t mvalue = 0;
- /* int mtype;
- int type; */
-
- mask.s_addr = 0;
- fwd_addr.s_addr = 0;
-
- /* Put Network Mask. */
- /* masklen2ip (p->prefixlen, &mask); */
- stream_put_ipv4 (s, mask.s_addr);
-
- /* If prefix is default, specify DEFAULT_ROUTE. */
- /* type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
-
- mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ?
- ROUTEMAP_METRIC_TYPE (ei) : metric_type (type);
-
- mvalue = (ROUTEMAP_METRIC (ei) != -1) ?
- ROUTEMAP_METRIC (ei) : metric_value (type); */
-
- /* Put type of external metric. */
- stream_putc (s, 0);
-
- /* Put 0 metric. TOS metric is not supported. */
- stream_put_ospf_metric (s, mvalue);
-
-
- /* fwd_addr = ospf_top->router_id; */
-
- /* OLD == ospf_external_lsa_nexthop_get (ei->nexthop); */
-
- /* Put forwarding address. */
- /* stream_put_ipv4 (s, fwd_addr.s_addr); */
- stream_put_ipv4 (s, ospf_top->router_id.s_addr);
-
- /* Put route tag -- This value should be introduced from configuration. */
- stream_putl (s, 0);
-}
-
/* As Type-7 */
void
-ospf_install_flood_nssa (struct ospf_lsa *lsa, struct external_info *ei)
+ospf_install_flood_nssa (struct ospf *ospf,
+ struct ospf_lsa *lsa, struct external_info *ei)
{
struct ospf_lsa *new2;
struct as_external_lsa *extlsa;
+ listnode node;
/* NSSA Originate or Refresh (If anyNSSA)
@@ -1607,58 +1626,59 @@ ospf_install_flood_nssa (struct ospf_lsa *lsa, struct external_info *ei)
Later, ABR_TASK and P-bit will scan Type-7 LSDB and translate to
Type-5's to non-NSSA Areas. (it will also attempt a re-install) */
- /* make lsa duplicate, lock=1 */
- new2 = ospf_lsa_dup(lsa);
-
- /* make type-7 */
- new2->data->type = OSPF_AS_NSSA_LSA;
-
- /* set P-bit if not ABR */
- if (! OSPF_IS_ABR)
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
- SET_FLAG(new2->data->options, OSPF_OPTION_NP);
+ struct ospf_area *area = getdata (node);
- /* set non-zero FWD ADDR
+ /* make lsa duplicate, lock=1 */
+ new2 = ospf_lsa_dup (lsa);
- draft-ietf-ospf-nssa-update-09.txt
+ new2->area = area;
+ new2->data->type = OSPF_AS_NSSA_LSA;
- if the network between the NSSA AS boundary router and the
- adjacent AS is advertised into OSPF as an internal OSPF route,
- the forwarding address should be the next op address as is cu
- currently done with type-5 LSAs. If the intervening network is
- not adversited into OSPF as an internal OSPF route and the
- type-7 LSA's P-bit is set a forwarding address should be
- selected from one of the router's active OSPF inteface addresses
- which belong to the NSSA. If no such addresses exist, then
- no type-7 LSA's with the P-bit set should originate from this
- router. */
+ /* set P-bit if not ABR */
+ if (! OSPF_IS_ABR)
+ {
+ SET_FLAG(new2->data->options, OSPF_OPTION_NP);
+
+ /* set non-zero FWD ADDR
+
+ draft-ietf-ospf-nssa-update-09.txt
+
+ if the network between the NSSA AS boundary router and the
+ adjacent AS is advertised into OSPF as an internal OSPF route,
+ the forwarding address should be the next op address as is cu
+ currently done with type-5 LSAs. If the intervening network is
+ not adversited into OSPF as an internal OSPF route and the
+ type-7 LSA's P-bit is set a forwarding address should be
+ selected from one of the router's active OSPF inteface addresses
+ which belong to the NSSA. If no such addresses exist, then
+ no type-7 LSA's with the P-bit set should originate from this
+ router. */
+
+ /* kevinm: not updating lsa anymore, just new2 */
+ extlsa = (struct as_external_lsa *)(new2->data);
+
+ if (extlsa->e[0].fwd_addr.s_addr == 0)
+ extlsa->e[0].fwd_addr = ospf_get_nssa_ip(area); /* this NSSA area in ifp */
- extlsa = (struct as_external_lsa *)(lsa->data);
+ if (IS_DEBUG_OSPF_NSSA)
+ if (extlsa->e[0].fwd_addr.s_addr == 0)
+ {
+ zlog_info ("LSA[Type-7]: Could not build FWD-ADDR");
+ ospf_lsa_discard(new2);
+ return;
+ }
+ }
+ /* Re-calculate checksum. */
+ ospf_lsa_checksum (new2->data);
- if (extlsa->e[0].fwd_addr.s_addr == 0)
- extlsa->e[0].fwd_addr = ospf_get_nssa_ip(); /* this NSSA area in ifp */
+ /* install also as Type-7 */
+ ospf_lsa_install (ospf, NULL, new2); /* Remove Old, Lock New = 2 */
- if (IS_DEBUG_OSPF_NSSA)
- if (extlsa->e[0].fwd_addr.s_addr == 0)
- {
- zlog_info ("LSA[Type-7]: Could not build FWD-ADDR");
- ospf_lsa_discard(new2);
- return;
- }
+ /* will send each copy, lock=2+n */
+ ospf_flood_through_as (ospf, NULL, new2); /* all attached NSSA's, no AS/STUBs */
}
-
- /* Re-calculate checksum. */
- ospf_lsa_checksum (new2->data);
-
- /* install also as Type-7 */
- ospf_lsa_install (NULL, new2); /* Remove Old, Lock New = 2 */
-
- /* will send each copy, lock=2+n */
- ospf_flood_through_as (NULL, new2); /* all attached NSSA's, no AS/STUBs */
-
- /* last send, lock=2 LSA is now permanent in Type-7 LSDB */
- /* It has the same ID as it's Type-5 Counter-Part */
-
}
#endif /* HAVE_NSSA */
@@ -1676,7 +1696,7 @@ is_prefix_default (struct prefix_ipv4 *p)
/* Originate an AS-external-LSA, install and flood. */
struct ospf_lsa *
-ospf_external_lsa_originate (struct external_info *ei)
+ospf_external_lsa_originate (struct ospf *ospf, struct external_info *ei)
{
struct ospf_lsa *new;
@@ -1716,11 +1736,11 @@ ospf_external_lsa_originate (struct external_info *ei)
*/
/* Check the AS-external-LSA should be originated. */
- if (!ospf_redistribute_check (ei, NULL))
+ if (!ospf_redistribute_check (ospf, ei, NULL))
return NULL;
/* Create new AS-external-LSA instance. */
- if ((new = ospf_external_lsa_new (ei, NULL)) == NULL)
+ if ((new = ospf_external_lsa_new (ospf, ei, NULL)) == NULL)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("LSA[Type5:%s]: Could not originate AS-external-LSA",
@@ -1729,18 +1749,18 @@ ospf_external_lsa_originate (struct external_info *ei)
}
/* Install newly created LSA into Type-5 LSDB, lock = 1. */
- ospf_lsa_install (NULL, new);
+ ospf_lsa_install (ospf, NULL, new);
/* Update LSA origination count. */
- ospf_top->lsa_originate_count++;
+ ospf->lsa_originate_count++;
/* Flooding new LSA. only to AS (non-NSSA/STUB) */
- ospf_flood_through_as (NULL, new);
+ ospf_flood_through_as (ospf, NULL, new);
#ifdef HAVE_NSSA
/* If there is any attached NSSA, do special handling */
- if (ospf_top->anyNSSA)
- ospf_install_flood_nssa (new, ei); /* Install/Flood Type-7 to all NSSAs */
+ if (ospf->anyNSSA)
+ ospf_install_flood_nssa (ospf, new, ei); /* Install/Flood Type-7 to all NSSAs */
#endif /* HAVE_NSSA */
/* Debug logging. */
@@ -1756,22 +1776,22 @@ ospf_external_lsa_originate (struct external_info *ei)
/* Originate AS-external-LSA from external info with initial flag. */
int
-ospf_external_lsa_originate_timer (struct thread *t)
+ospf_external_lsa_originate_timer (struct thread *thread)
{
+ struct ospf *ospf = THREAD_ARG (thread);
struct route_node *rn;
struct external_info *ei;
struct route_table *rt;
- int type;
+ int type = THREAD_VAL (thread);
- ospf_top->t_external_lsa = NULL;
- type = THREAD_VAL (t);
+ ospf->t_external_lsa = NULL;
/* Originate As-external-LSA from all type of distribute source. */
if ((rt = EXTERNAL_INFO (type)))
for (rn = route_top (rt); rn; rn = route_next (rn))
if ((ei = rn->info) != NULL)
if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
- if (!ospf_external_lsa_originate (ei))
+ if (!ospf_external_lsa_originate (ospf, ei))
zlog_warn ("LSA: AS-external-LSA was not originated.");
return 0;
@@ -1783,6 +1803,7 @@ ospf_default_external_info ()
int type;
struct route_node *rn;
struct prefix_ipv4 p;
+ struct ospf *ospf = ospf_top;
p.family = AF_INET;
p.prefix.s_addr = 0;
@@ -1797,7 +1818,7 @@ ospf_default_external_info ()
{
route_unlock_node (rn);
assert (rn->info);
- if (ospf_redistribute_check (rn->info, NULL))
+ if (ospf_redistribute_check (ospf, rn->info, NULL))
return rn->info;
}
}
@@ -1806,15 +1827,16 @@ ospf_default_external_info ()
}
int
-ospf_default_originate_timer (struct thread *t)
+ospf_default_originate_timer (struct thread *thread)
{
int *origin;
struct prefix_ipv4 p;
struct in_addr nexthop;
struct external_info *ei;
+ struct ospf *ospf = ospf_top;
/* Get originate flags. */
- origin = THREAD_ARG (t);
+ origin = THREAD_ARG (thread);
p.family = AF_INET;
p.prefix.s_addr = 0;
@@ -1829,14 +1851,15 @@ ospf_default_originate_timer (struct thread *t)
}
if ((ei = ospf_default_external_info ()))
- ospf_external_lsa_originate (ei);
+ ospf_external_lsa_originate (ospf, ei);
return 0;
}
/* Flush an AS-external-LSA from LSDB and routing domain. */
void
-ospf_external_lsa_flush (u_char type, struct prefix_ipv4 *p,
+ospf_external_lsa_flush (struct ospf *ospf,
+ u_char type, struct prefix_ipv4 *p,
unsigned int ifindex, struct in_addr nexthop)
{
struct ospf_lsa *lsa;
@@ -1846,7 +1869,7 @@ ospf_external_lsa_flush (u_char type, struct prefix_ipv4 *p,
inet_ntoa (p->prefix), p->prefixlen);
/* First lookup LSA from LSDB. */
- if (!(lsa = ospf_external_info_find_lsa (p)))
+ if (!(lsa = ospf_external_info_find_lsa (ospf, p)))
{
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_warn ("LSA: There is no such AS-external-LSA %s/%d in LSDB",
@@ -1855,7 +1878,7 @@ ospf_external_lsa_flush (u_char type, struct prefix_ipv4 *p,
}
/* Sweep LSA from Link State Retransmit List. */
- ospf_ls_retransmit_delete_nbr_all (NULL, lsa);
+ ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
/* There must be no self-originated LSA in rtrs_external. */
#if 0
@@ -1866,10 +1889,10 @@ ospf_external_lsa_flush (u_char type, struct prefix_ipv4 *p,
if (!IS_LSA_MAXAGE (lsa))
{
/* Unregister LSA from Refresh queue. */
- ospf_refresher_unregister_lsa (ospf_top, lsa);
+ ospf_refresher_unregister_lsa (ospf, lsa);
/* Flush AS-external-LSA through AS. */
- ospf_flush_through_as (lsa);
+ ospf_lsa_flush_as (ospf, lsa);
}
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
@@ -1877,7 +1900,7 @@ ospf_external_lsa_flush (u_char type, struct prefix_ipv4 *p,
}
void
-ospf_external_lsa_refresh_default ()
+ospf_external_lsa_refresh_default (struct ospf *ospf)
{
struct prefix_ipv4 p;
struct external_info *ei;
@@ -1888,7 +1911,7 @@ ospf_external_lsa_refresh_default ()
p.prefix.s_addr = 0;
ei = ospf_default_external_info ();
- lsa = ospf_external_info_find_lsa (&p);
+ lsa = ospf_external_info_find_lsa (ospf, &p);
if (ei)
{
@@ -1896,13 +1919,13 @@ ospf_external_lsa_refresh_default ()
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("LSA[Type5:0.0.0.0]: Refresh AS-external-LSA %p", lsa);
- ospf_external_lsa_refresh (lsa, ei, LSA_REFRESH_FORCE);
+ ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);
}
else
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("LSA[Type5:0.0.0.0]: Originate AS-external-LSA");
- ospf_external_lsa_originate (ei);
+ ospf_external_lsa_originate (ospf, ei);
}
}
else
@@ -1911,13 +1934,13 @@ ospf_external_lsa_refresh_default ()
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("LSA[Type5:0.0.0.0]: Flush AS-external-LSA");
- ospf_lsa_flush_as (lsa);
+ ospf_lsa_flush_as (ospf, lsa);
}
}
}
void
-ospf_external_lsa_refresh_type (u_char type, int force)
+ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, int force)
{
struct route_node *rn;
struct external_info *ei;
@@ -1931,25 +1954,26 @@ ospf_external_lsa_refresh_type (u_char type, int force)
{
struct ospf_lsa *lsa;
- if ((lsa = ospf_external_info_find_lsa (&ei->p)))
- ospf_external_lsa_refresh (lsa, ei, force);
+ if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p)))
+ ospf_external_lsa_refresh (ospf, lsa, ei, force);
else
- ospf_external_lsa_originate (ei);
+ ospf_external_lsa_originate (ospf, ei);
}
}
/* Refresh AS-external-LSA. */
void
-ospf_external_lsa_refresh (struct ospf_lsa *lsa,
+ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
struct external_info *ei, int force)
{
struct ospf_lsa *new;
int changed;
/* Check the AS-external-LSA should be originated. */
- if (!ospf_redistribute_check (ei, &changed))
+ if (!ospf_redistribute_check (ospf, ei, &changed))
{
- ospf_external_lsa_flush (ei->type, &ei->p, ei->ifindex, ei->nexthop);
+ ospf_external_lsa_flush (ospf, ei->type, &ei->p,
+ ei->ifindex, ei->nexthop);
return;
}
@@ -1957,12 +1981,12 @@ ospf_external_lsa_refresh (struct ospf_lsa *lsa,
return;
/* Delete LSA from neighbor retransmit-list. */
- ospf_ls_retransmit_delete_nbr_all (NULL, lsa);
+ ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
/* Unregister AS-external-LSA from refresh-list. */
- ospf_refresher_unregister_lsa (ospf_top, lsa);
+ ospf_refresher_unregister_lsa (ospf, lsa);
- new = ospf_external_lsa_new (ei, &lsa->data->id);
+ new = ospf_external_lsa_new (ospf, ei, &lsa->data->id);
if (new == NULL)
{
@@ -1980,19 +2004,19 @@ ospf_external_lsa_refresh (struct ospf_lsa *lsa,
/* Re-calculate checksum. */
ospf_lsa_checksum (new->data);
- ospf_lsa_install (NULL, new); /* As type-5. */
+ ospf_lsa_install (ospf, NULL, new); /* As type-5. */
/* Flood LSA through AS. */
- ospf_flood_through_as (NULL, new);
+ ospf_flood_through_as (ospf, NULL, new);
#ifdef HAVE_NSSA
/* If any attached NSSA, install as Type-7, flood to all NSSA Areas */
- if (ospf_top->anyNSSA)
- ospf_install_flood_nssa (new, ei); /* Install/Flood per new rules */
+ if (ospf->anyNSSA)
+ ospf_install_flood_nssa (ospf, new, ei); /* Install/Flood per new rules */
#endif /* HAVE_NSSA */
/* Register slef-originated LSA to refresh queue. */
- ospf_refresher_register_lsa (ospf_top, new);
+ ospf_refresher_register_lsa (ospf, new);
/* Debug logging. */
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
@@ -2010,7 +2034,8 @@ ospf_external_lsa_refresh (struct ospf_lsa *lsa,
/* Install router-LSA to an area. */
struct ospf_lsa *
-ospf_router_lsa_install (struct ospf_lsa *new, int rt_recalc)
+ospf_router_lsa_install (struct ospf *ospf,
+ struct ospf_lsa *new, int rt_recalc)
{
struct ospf_area *area = new->area;
@@ -2020,7 +2045,7 @@ ospf_router_lsa_install (struct ospf_lsa *new, int rt_recalc)
area whose link-state database has changed).
*/
if (rt_recalc)
- ospf_spf_calculate_schedule();
+ ospf_spf_calculate_schedule (ospf);
if (IS_LSA_SELF (new))
{
@@ -2047,7 +2072,8 @@ ospf_router_lsa_install (struct ospf_lsa *new, int rt_recalc)
/* Install network-LSA to an area. */
struct ospf_lsa *
-ospf_network_lsa_install (struct ospf_interface *oi,
+ospf_network_lsa_install (struct ospf *ospf,
+ struct ospf_interface *oi,
struct ospf_lsa *new,
int rt_recalc)
{
@@ -2058,7 +2084,7 @@ ospf_network_lsa_install (struct ospf_interface *oi,
area whose link-state database has changed).
*/
if (rt_recalc)
- ospf_spf_calculate_schedule();
+ ospf_spf_calculate_schedule (ospf);
/* We supposed that when LSA is originated by us, we pass the int
for which it was originated. If LSA was received by flooding,
@@ -2081,9 +2107,9 @@ ospf_network_lsa_install (struct ospf_interface *oi,
/* Install summary-LSA to an area. */
struct ospf_lsa *
-ospf_summary_lsa_install (struct ospf_lsa *new, int rt_recalc)
+ospf_summary_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
+ int rt_recalc)
{
-
if (rt_recalc && !IS_LSA_SELF (new))
{
/* RFC 2328 Section 13.2 Summary-LSAs
@@ -2097,7 +2123,7 @@ ospf_summary_lsa_install (struct ospf_lsa *new, int rt_recalc)
/* This doesn't exist yet... */
ospf_summary_incremental_update(new); */
#else /* #if 0 */
- ospf_spf_calculate_schedule();
+ ospf_spf_calculate_schedule (ospf);
#endif /* #if 0 */
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
@@ -2105,14 +2131,15 @@ ospf_summary_lsa_install (struct ospf_lsa *new, int rt_recalc)
}
if (IS_LSA_SELF (new))
- ospf_refresher_register_lsa (ospf_top, new);
+ ospf_refresher_register_lsa (ospf, new);
return new;
}
/* Install ASBR-summary-LSA to an area. */
struct ospf_lsa *
-ospf_summary_asbr_lsa_install (struct ospf_lsa *new, int rt_recalc)
+ospf_summary_asbr_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
+ int rt_recalc)
{
if (rt_recalc && !IS_LSA_SELF (new))
{
@@ -2129,22 +2156,23 @@ ospf_summary_asbr_lsa_install (struct ospf_lsa *new, int rt_recalc)
- RFC 2328 Section 16.5 implies it should be */
/* ospf_ase_calculate_schedule(); */
#else /* #if 0 */
- ospf_spf_calculate_schedule();
+ ospf_spf_calculate_schedule (ospf);
#endif /* #if 0 */
}
/* register LSA to refresh-list. */
if (IS_LSA_SELF (new))
- ospf_refresher_register_lsa (ospf_top, new);
+ ospf_refresher_register_lsa (ospf, new);
return new;
}
/* Install AS-external-LSA. */
struct ospf_lsa *
-ospf_external_lsa_install (struct ospf_lsa *new, int rt_recalc)
+ospf_external_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
+ int rt_recalc)
{
- ospf_ase_register_external_lsa (new, ospf_top);
+ ospf_ase_register_external_lsa (new, ospf);
/* If LSA is not self-originated, calculate an external route. */
if (rt_recalc)
{
@@ -2154,18 +2182,19 @@ ospf_external_lsa_install (struct ospf_lsa *new, int rt_recalc)
*/
if (!IS_LSA_SELF (new))
- ospf_ase_incremental_update (new, ospf_top);
+ ospf_ase_incremental_update (ospf, new);
}
/* Register self-originated LSA to refresh queue. */
if (IS_LSA_SELF (new))
- ospf_refresher_register_lsa (ospf_top, new);
+ ospf_refresher_register_lsa (ospf, new);
return new;
}
void
-ospf_discard_from_db (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
+ospf_discard_from_db (struct ospf *ospf,
+ struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
{
struct ospf_lsa *old;
@@ -2175,9 +2204,7 @@ ospf_discard_from_db (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
return;
if (old->refresh_list >= 0)
- ospf_refresher_unregister_lsa (ospf_top, old);
-
- ospf_ls_retransmit_delete_nbr_all (old->area, old);
+ ospf_refresher_unregister_lsa (ospf, old);
switch (old->data->type)
{
@@ -2185,31 +2212,21 @@ ospf_discard_from_db (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
- ospf_ase_unregister_external_lsa (old, ospf_top);
+ ospf_ls_retransmit_delete_nbr_as (ospf, old);
+ ospf_ase_unregister_external_lsa (old, ospf);
break;
default:
+ ospf_ls_retransmit_delete_nbr_area (old->area, old);
break;
}
- ospf_lsa_maxage_delete (old);
+ ospf_lsa_maxage_delete (ospf, old);
ospf_lsa_discard (old);
}
-/* callback for foreach_lsa */
-int
-ospf_lsa_discard_callback (struct ospf_lsa *lsa, void *p, int i)
-{
-#ifdef HAVE_NSSA
- /* Removed: Stay away from any Local Translated Type-7 LSAs */
- /* if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
- return 0; */
-#endif /* HAVE_NSSA */
- ospf_discard_from_db ((struct ospf_lsdb *)p, lsa);
- return 0;
-}
-
struct ospf_lsa *
-ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
+ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
+ struct ospf_lsa *lsa)
{
struct ospf_lsa *new = NULL;
struct ospf_lsa *old = NULL;
@@ -2219,27 +2236,26 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
/* Set LSDB. */
switch (lsa->data->type)
{
+#ifdef HAVE_NSSA
+ /* kevinm */
+ case OSPF_AS_NSSA_LSA:
+ if (lsa->area)
+ lsdb = lsa->area->lsdb;
+ else
+ lsdb = ospf->lsdb;
+ break;
+#endif /* HAVE_NSSA */
case OSPF_AS_EXTERNAL_LSA:
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
- lsdb = ospf_top->lsdb;
+ lsdb = ospf->lsdb;
break;
default:
lsdb = lsa->area->lsdb;
break;
}
-#ifdef HAVE_NSSA
- if (IS_DEBUG_OSPF_NSSA)
- {
- zlog_info ("LSA[Installing]: Type-%d ", lsa->data->type);
-
- if (lsa->data->type == OSPF_AS_NSSA_LSA )
- zlog_info ("NSSA LSA AREA = %s", inet_ntoa (lsa->area->area_id));
- }
-#endif /* HAVE_NSSA */
-
assert (lsdb);
/* RFC 2328 13.2. Installing LSAs in the database
@@ -2275,7 +2291,7 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
/* discard old LSA from LSDB */
if (old != NULL)
- ospf_discard_from_db (lsdb, lsa);
+ ospf_discard_from_db (ospf, lsdb, lsa);
/* Insert LSA to LSDB. */
ospf_lsdb_add (lsdb, lsa);
@@ -2289,27 +2305,27 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
switch (lsa->data->type)
{
case OSPF_ROUTER_LSA:
- new = ospf_router_lsa_install (lsa, rt_recalc);
+ new = ospf_router_lsa_install (ospf, lsa, rt_recalc);
break;
case OSPF_NETWORK_LSA:
assert (oi);
- new = ospf_network_lsa_install (oi, lsa, rt_recalc);
+ new = ospf_network_lsa_install (ospf, oi, lsa, rt_recalc);
break;
case OSPF_SUMMARY_LSA:
- new = ospf_summary_lsa_install (lsa, rt_recalc);
+ new = ospf_summary_lsa_install (ospf, lsa, rt_recalc);
break;
case OSPF_ASBR_SUMMARY_LSA:
- new = ospf_summary_asbr_lsa_install (lsa, rt_recalc);
+ new = ospf_summary_asbr_lsa_install (ospf, lsa, rt_recalc);
break;
case OSPF_AS_EXTERNAL_LSA:
- new = ospf_external_lsa_install (lsa, rt_recalc);
+ new = ospf_external_lsa_install (ospf, lsa, rt_recalc);
break;
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_LINK_LSA:
if (IS_LSA_SELF (lsa))
- lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
+ lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
else
- ; /* Incoming "oi" for this LSA has set at LSUpd reception. */
+ ; /* Incoming "oi" for this LSA has set at LSUpd reception. */
/* Fallthrough */
case OSPF_OPAQUE_AREA_LSA:
case OSPF_OPAQUE_AS_LSA:
@@ -2318,7 +2334,7 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
#endif /* HAVE_OPAQUE_LSA */
default: /* NSSA, or type-6,8,9....nothing special */
#ifdef HAVE_NSSA
- new = ospf_external_lsa_install (lsa, rt_recalc);
+ new = ospf_external_lsa_install (ospf, lsa, rt_recalc);
#endif /* HAVE_NSSA */
break;
}
@@ -2337,6 +2353,9 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_AS_LSA:
#endif /* HAVE_OPAQUE_LSA */
+#ifdef HAVE_NSSA
+ case OSPF_AS_NSSA_LSA:
+#endif /* HAVE_NSSA */
zlog_info ("LSA[%s]: Install %s",
dump_lsa_key (new),
LOOKUP (ospf_lsa_type_msg, new->data->type));
@@ -2356,7 +2375,7 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_info ("LSA[Type%d:%s]: Install LSA, MaxAge",
new->data->type, inet_ntoa (new->data->id));
- ospf_lsa_maxage (lsa);
+ ospf_lsa_maxage (ospf, lsa);
}
return new;
@@ -2364,11 +2383,11 @@ ospf_lsa_install (struct ospf_interface *oi, struct ospf_lsa *lsa)
int
-ospf_check_nbr_status ()
+ospf_check_nbr_status (struct ospf *ospf)
{
listnode node;
- for (node = listhead (ospf_top->oiflist); node; node = nextnode (node))
+ for (node = listhead (ospf->oiflist); node; node = nextnode (node))
{
struct ospf_interface *oi = getdata (node);
struct route_node *rn;
@@ -2423,19 +2442,20 @@ ospf_maxage_flood (struct ospf_lsa *lsa)
int
ospf_maxage_lsa_remover (struct thread *thread)
{
+ struct ospf *ospf = THREAD_ARG (thread);
listnode node;
listnode next;
int reschedule = 0;
- ospf_top->t_maxage = NULL;
+ ospf->t_maxage = NULL;
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_info ("LSA[MaxAge]: remover Start");
- reschedule = !ospf_check_nbr_status ();
+ reschedule = !ospf_check_nbr_status (ospf);
if (!reschedule)
- for (node = listhead (ospf_top->maxage_lsa); node; node = next)
+ for (node = listhead (ospf->maxage_lsa); node; node = next)
{
struct ospf_lsa *lsa = getdata (node);
next = node->next;
@@ -2460,11 +2480,11 @@ ospf_maxage_lsa_remover (struct thread *thread)
#ifdef ORIGINAL_CODING
ospf_maxage_flood (lsa);
#else /* ORIGINAL_CODING */
- ospf_flood_through (NULL, lsa);
+ ospf_flood_through (ospf, NULL, lsa);
#endif /* ORIGINAL_CODING */
/* Remove from lsdb. */
- ospf_discard_from_db (lsa->lsdb, lsa);
+ ospf_discard_from_db (ospf, lsa->lsdb, lsa);
ospf_lsdb_delete (lsa->lsdb, lsa);
}
@@ -2473,17 +2493,17 @@ ospf_maxage_lsa_remover (struct thread *thread)
neighbor Link state retransmission lists and b) none of the router's
neighbors are in states Exchange or Loading. */
if (reschedule)
- OSPF_SCHEDULE_MAXAGE (ospf_top->t_maxage, ospf_maxage_lsa_remover);
+ OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 2);
return 0;
}
int
-ospf_lsa_maxage_exist (struct ospf_lsa *new)
+ospf_lsa_maxage_exist (struct ospf *ospf, struct ospf_lsa *new)
{
listnode node;
- for (node = listhead (ospf_top->maxage_lsa); node; nextnode (node))
+ for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
if (((struct ospf_lsa *) node->data) == new)
return 1;
@@ -2491,23 +2511,23 @@ ospf_lsa_maxage_exist (struct ospf_lsa *new)
}
void
-ospf_lsa_maxage_delete (struct ospf_lsa *lsa)
+ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa)
{
listnode n;
- if ((n = listnode_lookup (ospf_top->maxage_lsa, lsa)))
+ if ((n = listnode_lookup (ospf->maxage_lsa, lsa)))
{
- list_delete_node (ospf_top->maxage_lsa, n);
+ list_delete_node (ospf->maxage_lsa, n);
ospf_lsa_unlock (lsa);
}
}
void
-ospf_lsa_maxage (struct ospf_lsa *lsa)
+ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *lsa)
{
/* When we saw a MaxAge LSA flooded to us, we put it on the list
and schedule the MaxAge LSA remover. */
- if (ospf_lsa_maxage_exist (lsa))
+ if (ospf_lsa_maxage_exist (ospf, lsa))
{
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_info ("LSA[Type%d:%s]: %p already exists on MaxAge LSA list",
@@ -2515,16 +2535,16 @@ ospf_lsa_maxage (struct ospf_lsa *lsa)
return;
}
- listnode_add (ospf_top->maxage_lsa, ospf_lsa_lock (lsa));
+ listnode_add (ospf->maxage_lsa, ospf_lsa_lock (lsa));
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_info ("LSA[%s]: MaxAge LSA remover scheduled.", dump_lsa_key (lsa));
- OSPF_SCHEDULE_MAXAGE (ospf_top->t_maxage, ospf_maxage_lsa_remover);
+ OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 2);
}
int
-ospf_lsa_maxage_walker_remover (struct ospf_lsa *lsa, void *p_arg, int int_arg)
+ospf_lsa_maxage_walker_remover (struct ospf *ospf, struct ospf_lsa *lsa)
{
#ifdef HAVE_NSSA
/* Stay away from any Local Translated Type-7 LSAs */
@@ -2535,7 +2555,7 @@ ospf_lsa_maxage_walker_remover (struct ospf_lsa *lsa, void *p_arg, int int_arg)
if (IS_LSA_MAXAGE (lsa))
/* Self-originated LSAs should NOT time-out instead,
they're flushed and submitted to the max_age list explicitly. */
- if (!ospf_lsa_is_self_originated (lsa))
+ if (!ospf_lsa_is_self_originated (ospf, lsa))
{
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_info("LSA[%s]: is MaxAge", dump_lsa_key (lsa));
@@ -2557,14 +2577,17 @@ ospf_lsa_maxage_walker_remover (struct ospf_lsa *lsa, void *p_arg, int int_arg)
break;
#endif /* HAVE_OPAQUE_LSA */
case OSPF_AS_EXTERNAL_LSA:
- ospf_ase_incremental_update (lsa, ospf_top);
+#ifdef HAVE_NSSA
+ case OSPF_AS_NSSA_LSA:
+#endif /* HAVE_NSSA */
+ ospf_ase_incremental_update (ospf, lsa);
break;
default:
- ospf_spf_calculate_schedule ();
+ ospf_spf_calculate_schedule (ospf);
break;
}
- ospf_lsa_maxage (lsa);
+ ospf_lsa_maxage (ospf, lsa);
}
return 0;
@@ -2572,90 +2595,80 @@ ospf_lsa_maxage_walker_remover (struct ospf_lsa *lsa, void *p_arg, int int_arg)
/* Periodical check of MaxAge LSA. */
int
-ospf_lsa_maxage_walker (struct thread *t)
+ospf_lsa_maxage_walker (struct thread *thread)
{
+ struct ospf *ospf = THREAD_ARG (thread);
+ struct route_node *rn;
+ struct ospf_lsa *lsa;
listnode node;
- ospf_top->t_maxage_walker = NULL;
+ ospf->t_maxage_walker = NULL;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = node->data;
- foreach_lsa (ROUTER_LSDB (area), NULL, 0,
- ospf_lsa_maxage_walker_remover);
- foreach_lsa (NETWORK_LSDB (area), NULL, 0,
- ospf_lsa_maxage_walker_remover);
- foreach_lsa (SUMMARY_LSDB (area), NULL, 0,
- ospf_lsa_maxage_walker_remover);
- foreach_lsa (ASBR_SUMMARY_LSDB (area), NULL, 0,
- ospf_lsa_maxage_walker_remover);
+ LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
+ LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
+ LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
+ LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
#ifdef HAVE_OPAQUE_LSA
- foreach_lsa (OPAQUE_LINK_LSDB (area), NULL, 0,
- ospf_lsa_maxage_walker_remover);
- foreach_lsa (OPAQUE_AREA_LSDB (area), NULL, 0,
- ospf_lsa_maxage_walker_remover);
+ LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
+ LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
#endif /* HAVE_OPAQUE_LSA */
}
/* for AS-eternal-LSAs. */
- if (ospf_top->lsdb)
- foreach_lsa (EXTERNAL_LSDB (ospf_top), NULL, 0,
- ospf_lsa_maxage_walker_remover);
-
+ if (ospf->lsdb)
+ {
+ LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
#ifdef HAVE_OPAQUE_LSA
- if (ospf_top->lsdb)
- foreach_lsa (OPAQUE_AS_LSDB (ospf_top), NULL, 0,
- ospf_lsa_maxage_walker_remover);
+ LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
+ ospf_lsa_maxage_walker_remover (ospf, lsa);
#endif /* HAVE_OPAQUE_LSA */
+ }
- ospf_top->t_maxage_walker =
- thread_add_timer (master, ospf_lsa_maxage_walker, NULL,
- OSPF_LSA_MAXAGE_CHECK_INTERVAL);
+ OSPF_TIMER_ON (ospf->t_maxage_walker, ospf_lsa_maxage_walker,
+ OSPF_LSA_MAXAGE_CHECK_INTERVAL);
return 0;
}
-int
-find_summary (struct ospf_lsa *lsa, void * v, int i)
+struct ospf_lsa *
+ospf_lsa_lookup_by_prefix (struct ospf_lsdb *lsdb, u_char type,
+ struct prefix_ipv4 *p, struct in_addr router_id)
{
- struct prefix_ipv4 *p, pr;
-
- if ((p = (struct prefix_ipv4 *) v) != NULL)
- if (lsa != NULL)
- /* We're looking for self-originated one */
- if (ospf_lsa_is_self_originated (lsa))
- {
- struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
-
- pr.family = AF_INET;
- pr.prefix = sl->header.id;
- pr.prefixlen = ip_masklen (sl->mask);
- apply_mask_ipv4 (&pr);
-
- if (prefix_same ((struct prefix*) &pr, (struct prefix*) p))
- return 1;
- }
+ struct ospf_lsa *lsa;
+ struct in_addr mask, id;
+ struct lsa_header_mask
+ {
+ struct lsa_header header;
+ struct in_addr mask;
+ } *hmask;
- return 0;
-}
+ lsa = ospf_lsdb_lookup_by_id (lsdb, type, p->prefix, router_id);
+ if (lsa == NULL)
+ return NULL;
-int
-find_asbr_summary (struct ospf_lsa *lsa, void * v, int i)
-{
- struct prefix_ipv4 *p;
+ masklen2ip (p->prefixlen, &mask);
- if ((p = (struct prefix_ipv4 *) v) != NULL)
- if (lsa != NULL)
- /* We're looking for self-originated one */
- if (ospf_lsa_is_self_originated (lsa))
- {
- struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
+ hmask = (struct lsa_header_mask *) lsa->data;
- if (IPV4_ADDR_SAME (&p->prefix, &sl->header.id))
- return 1;
- }
+ if (mask.s_addr != hmask->mask.s_addr)
+ {
+ id.s_addr = p->prefix.s_addr | (~mask.s_addr);
+ lsa = ospf_lsdb_lookup_by_id (lsdb, type, id, router_id);
+ if (!lsa)
+ return NULL;
+ }
- return 0;
+ return lsa;
}
struct ospf_lsa *
@@ -2879,7 +2892,7 @@ ospf_lsa_flush_self_originated (struct ospf_neighbor *nbr,
}
#else /* ORIGINAL_CODING */
static int
-ospf_lsa_flush_schedule (struct ospf_lsa *lsa, void *v, int i)
+ospf_lsa_flush_schedule (struct ospf *ospf, struct ospf_lsa *lsa)
{
if (lsa == NULL || !IS_LSA_SELF (lsa))
return 0;
@@ -2900,7 +2913,7 @@ ospf_lsa_flush_schedule (struct ospf_lsa *lsa, void *v, int i)
break;
#endif /* HAVE_OPAQUE_LSA */
default:
- ospf_lsa_maxage (lsa);
+ ospf_lsa_maxage (ospf, lsa);
break;
}
@@ -2908,15 +2921,16 @@ ospf_lsa_flush_schedule (struct ospf_lsa *lsa, void *v, int i)
}
void
-ospf_flush_self_originated_lsas_now (struct ospf *top)
+ospf_flush_self_originated_lsas_now (struct ospf *ospf)
{
listnode n1, n2;
struct ospf_area *area;
struct ospf_interface *oi;
struct ospf_lsa *lsa;
+ struct route_node *rn;
int need_to_flush_ase = 0;
- for (n1 = listhead (top->areas); n1; nextnode (n1))
+ for (n1 = listhead (ospf->areas); n1; nextnode (n1))
{
if ((area = getdata (n1)) == NULL)
continue;
@@ -2955,22 +2969,25 @@ ospf_flush_self_originated_lsas_now (struct ospf *top)
need_to_flush_ase = 1;
}
- foreach_lsa (SUMMARY_LSDB (area), NULL, 0, ospf_lsa_flush_schedule);
- foreach_lsa (ASBR_SUMMARY_LSDB (area), NULL, 0, ospf_lsa_flush_schedule);
+ LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
+ ospf_lsa_flush_schedule (ospf, lsa);
+ LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
+ ospf_lsa_flush_schedule (ospf, lsa);
#ifdef HAVE_OPAQUE_LSA
- foreach_lsa (OPAQUE_LINK_LSDB (area),
- NULL, 0, ospf_lsa_flush_schedule);
- foreach_lsa (OPAQUE_AREA_LSDB (area),
- NULL, 0, ospf_lsa_flush_schedule);
+ LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
+ ospf_lsa_flush_schedule (ospf, lsa);
+ LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
+ ospf_lsa_flush_schedule (ospf, lsa);
#endif /* HAVE_OPAQUE_LSA */
}
if (need_to_flush_ase)
{
- foreach_lsa (EXTERNAL_LSDB (top), NULL, 0, ospf_lsa_flush_schedule);
+ LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
+ ospf_lsa_flush_schedule (ospf, lsa);
#ifdef HAVE_OPAQUE_LSA
- foreach_lsa (OPAQUE_AS_LSDB (top),
- NULL, 0, ospf_lsa_flush_schedule);
+ LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
+ ospf_lsa_flush_schedule (ospf, lsa);
#endif /* HAVE_OPAQUE_LSA */
}
@@ -2978,10 +2995,10 @@ ospf_flush_self_originated_lsas_now (struct ospf *top)
* Make sure that the MaxAge LSA remover is executed immediately,
* without conflicting to other threads.
*/
- if (top->t_maxage != NULL)
+ if (ospf->t_maxage != NULL)
{
- OSPF_TIMER_OFF (top->t_maxage);
- thread_execute (master, ospf_maxage_lsa_remover, top, 0);
+ OSPF_TIMER_OFF (ospf->t_maxage);
+ thread_execute (master, ospf_maxage_lsa_remover, ospf, 0);
}
return;
@@ -2991,7 +3008,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *top)
/* If there is self-originated LSA, then return 1, otherwise return 0. */
/* An interface-independent version of ospf_lsa_is_self_originated */
int
-ospf_lsa_is_self_originated (struct ospf_lsa *lsa)
+ospf_lsa_is_self_originated (struct ospf *ospf, struct ospf_lsa *lsa)
{
listnode node;
@@ -3003,17 +3020,17 @@ ospf_lsa_is_self_originated (struct ospf_lsa *lsa)
SET_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED);
/* AdvRouter and Router ID is the same. */
- if (IPV4_ADDR_SAME (&lsa->data->adv_router, &ospf_top->router_id))
+ if (IPV4_ADDR_SAME (&lsa->data->adv_router, &ospf->router_id))
SET_FLAG (lsa->flags, OSPF_LSA_SELF);
/* LSA is router-LSA. */
else if (lsa->data->type == OSPF_ROUTER_LSA &&
- IPV4_ADDR_SAME (&lsa->data->id, &ospf_top->router_id))
+ IPV4_ADDR_SAME (&lsa->data->id, &ospf->router_id))
SET_FLAG (lsa->flags, OSPF_LSA_SELF);
/* LSA is network-LSA. Compare Link ID with all interfaces. */
else if (lsa->data->type == OSPF_NETWORK_LSA)
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
@@ -3033,7 +3050,8 @@ ospf_lsa_is_self_originated (struct ospf_lsa *lsa)
/* Get unique Link State ID. */
struct in_addr
-ospf_lsa_unique_id (struct ospf_lsdb *lsdb, u_char type, struct prefix_ipv4 *p)
+ospf_lsa_unique_id (struct ospf *ospf,
+ struct ospf_lsdb *lsdb, u_char type, struct prefix_ipv4 *p)
{
struct ospf_lsa *lsa;
struct in_addr mask, id;
@@ -3041,7 +3059,7 @@ ospf_lsa_unique_id (struct ospf_lsdb *lsdb, u_char type, struct prefix_ipv4 *p)
id = p->prefix;
/* Check existence of LSA instance. */
- lsa = ospf_lsdb_lookup_by_id (lsdb, type, id, ospf_top->router_id);
+ lsa = ospf_lsdb_lookup_by_id (lsdb, type, id, ospf->router_id);
if (lsa)
{
struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
@@ -3061,8 +3079,8 @@ ospf_lsa_unique_id (struct ospf_lsdb *lsdb, u_char type, struct prefix_ipv4 *p)
masklen2ip (p->prefixlen, &mask);
id.s_addr = p->prefix.s_addr | (~mask.s_addr);
- lsa = ospf_lsdb_lookup_by_id (ospf_top->lsdb, type,
- id, ospf_top->router_id);
+ lsa = ospf_lsdb_lookup_by_id (ospf->lsdb, type,
+ id, ospf->router_id);
if (lsa)
{
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
@@ -3099,6 +3117,7 @@ int
ospf_lsa_action (struct thread *t)
{
struct lsa_action *data;
+ struct ospf *ospf = ospf_top;
data = THREAD_ARG (t);
@@ -3118,13 +3137,13 @@ ospf_lsa_action (struct thread *t)
ospf_flood_through_area (data->area, NULL, data->lsa);
break;
case LSA_ACTION_FLOOD_AS:
- ospf_flood_through_as (NULL, data->lsa);
+ ospf_flood_through_as (ospf, NULL, data->lsa);
break;
case LSA_ACTION_FLUSH_AREA:
ospf_lsa_flush_area (data->lsa, data->area);
break;
case LSA_ACTION_FLUSH_AS:
- ospf_lsa_flush_as (data->lsa);
+ ospf_lsa_flush_as (ospf, data->lsa);
break;
}
@@ -3166,7 +3185,7 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
/* LSA Refreshment functions. */
void
-ospf_lsa_refresh (struct ospf_lsa *lsa)
+ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{
struct external_info *ei;
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
@@ -3178,17 +3197,17 @@ ospf_lsa_refresh (struct ospf_lsa *lsa)
case OSPF_NETWORK_LSA:
break;
case OSPF_SUMMARY_LSA:
- ospf_summary_lsa_refresh (lsa);
+ ospf_summary_lsa_refresh (ospf, lsa);
break;
case OSPF_ASBR_SUMMARY_LSA:
- ospf_summary_asbr_lsa_refresh (lsa);
+ ospf_summary_asbr_lsa_refresh (ospf, lsa);
break;
case OSPF_AS_EXTERNAL_LSA:
ei = ospf_external_info_check (lsa);
if (ei)
- ospf_external_lsa_refresh (lsa, ei, LSA_REFRESH_FORCE);
+ ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);
else
- ospf_lsa_flush_as (lsa);
+ ospf_lsa_flush_as (ospf, lsa);
break;
#ifdef HAVE_OPAQUE_LSA
case OSPF_OPAQUE_LINK_LSA:
@@ -3203,7 +3222,7 @@ ospf_lsa_refresh (struct ospf_lsa *lsa)
}
void
-ospf_refresher_register_lsa (struct ospf *top, struct ospf_lsa *lsa)
+ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
{
u_int16_t index, current_index;
@@ -3225,8 +3244,8 @@ ospf_refresher_register_lsa (struct ospf *top, struct ospf_lsa *lsa)
if (delay < 0)
delay = 0;
- current_index = top->lsa_refresh_queue.index +
- (time (NULL) - top->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
+ current_index = ospf->lsa_refresh_queue.index +
+ (time (NULL) - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
% (OSPF_LSA_REFRESHER_SLOTS);
@@ -3234,25 +3253,25 @@ ospf_refresher_register_lsa (struct ospf *top, struct ospf_lsa *lsa)
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_info ("LSA[Refresh]: lsa with age %d added to index %d",
LS_AGE (lsa), index);
- if (!top->lsa_refresh_queue.qs[index])
- top->lsa_refresh_queue.qs[index] = list_new ();
- listnode_add (top->lsa_refresh_queue.qs[index], ospf_lsa_lock (lsa));
+ if (!ospf->lsa_refresh_queue.qs[index])
+ ospf->lsa_refresh_queue.qs[index] = list_new ();
+ listnode_add (ospf->lsa_refresh_queue.qs[index], ospf_lsa_lock (lsa));
lsa->refresh_list = index;
}
}
void
-ospf_refresher_unregister_lsa (struct ospf *top, struct ospf_lsa *lsa)
+ospf_refresher_unregister_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
{
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
if (lsa->refresh_list >= 0)
{
- list refresh_list = top->lsa_refresh_queue.qs[lsa->refresh_list];
+ list refresh_list = ospf->lsa_refresh_queue.qs[lsa->refresh_list];
listnode_delete (refresh_list, lsa);
if (!listcount (refresh_list))
{
list_free (refresh_list);
- top->lsa_refresh_queue.qs[lsa->refresh_list] = NULL;
+ ospf->lsa_refresh_queue.qs[lsa->refresh_list] = NULL;
}
ospf_lsa_unlock (lsa);
lsa->refresh_list = -1;
@@ -3264,7 +3283,7 @@ ospf_lsa_refresh_walker (struct thread *t)
{
list refresh_list;
listnode node;
- struct ospf *top = THREAD_ARG (t);
+ struct ospf *ospf = THREAD_ARG (t);
int i;
list lsa_to_refresh = list_new ();
@@ -3272,27 +3291,27 @@ ospf_lsa_refresh_walker (struct thread *t)
zlog_info ("LSA[Refresh]:ospf_lsa_refresh_walker(): start");
- i = top->lsa_refresh_queue.index;
+ i = ospf->lsa_refresh_queue.index;
- top->lsa_refresh_queue.index =
- (top->lsa_refresh_queue.index +
- (time (NULL) - top->lsa_refresher_started) / OSPF_LSA_REFRESHER_GRANULARITY)
+ ospf->lsa_refresh_queue.index =
+ (ospf->lsa_refresh_queue.index +
+ (time (NULL) - ospf->lsa_refresher_started) / OSPF_LSA_REFRESHER_GRANULARITY)
% OSPF_LSA_REFRESHER_SLOTS;
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_info ("LSA[Refresh]: ospf_lsa_refresh_walker(): next index %d",
- top->lsa_refresh_queue.index);
+ ospf->lsa_refresh_queue.index);
- for (;i != top->lsa_refresh_queue.index;
+ for (;i != ospf->lsa_refresh_queue.index;
i = (i + 1) % OSPF_LSA_REFRESHER_SLOTS)
{
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_info ("LSA[Refresh]: ospf_lsa_refresh_walker(): refresh index %d", i);
- refresh_list = top->lsa_refresh_queue.qs [i];
-
- top->lsa_refresh_queue.qs [i] = NULL;
+ refresh_list = ospf->lsa_refresh_queue.qs [i];
+ ospf->lsa_refresh_queue.qs [i] = NULL;
+
if (refresh_list)
{
for (node = listhead (refresh_list); node;)
@@ -3314,12 +3333,12 @@ ospf_lsa_refresh_walker (struct thread *t)
}
}
- top->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
- top, top->lsa_refresh_interval);
- top->lsa_refresher_started = time (NULL);
+ ospf->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
+ ospf, ospf->lsa_refresh_interval);
+ ospf->lsa_refresher_started = time (NULL);
for (node = listhead (lsa_to_refresh); node; nextnode (node))
- ospf_lsa_refresh (getdata (node));
+ ospf_lsa_refresh (ospf, getdata (node));
list_delete (lsa_to_refresh);
diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h
index 02fbe704..3271409f 100644
--- a/ospfd/ospf_lsa.h
+++ b/ospfd/ospf_lsa.h
@@ -207,14 +207,6 @@ struct as_external_lsa
#define IS_LSA_SELF(L) (CHECK_FLAG ((L)->flags, OSPF_LSA_SELF))
#define IS_LSA_MAXAGE(L) (LS_AGE ((L)) == OSPF_LSA_MAXAGE)
-#define OSPF_SUMMARY_LSA_SELF_FIND_BY_PREFIX(A,P) \
- foreach_lsa (SUMMARY_LSDB ((A)), \
- (struct prefix_ipv4 *) (P), 0, find_summary)
-
-#define OSPF_SUMMARY_ASBR_LSA_SELF_FIND_BY_PREFIX(A,P) \
- foreach_lsa (ASBR_SUMMARY_LSDB ((A)), \
- (struct prefix_ipv4 *) (P), 0, find_asbr_summary)
-
#define OSPF_LSA_UPDATE_DELAY 2
#define OSPF_LSA_UPDATE_TIMER_ON(T,F) \
@@ -237,15 +229,16 @@ int get_age (struct ospf_lsa *);
u_int16_t ospf_lsa_checksum (struct lsa_header *);
struct stream;
-const char *dump_lsa_key (struct ospf_lsa *lsa);
-u_int32_t lsa_seqnum_increment (struct ospf_lsa *lsa);
-void lsa_header_set (struct stream *s, u_char options, u_char type, struct in_addr id);
-struct ospf_neighbor *ospf_nbr_lookup_ptop (struct route_table *nbrs, struct in_addr router_id);
+const char *dump_lsa_key (struct ospf_lsa *);
+u_int32_t lsa_seqnum_increment (struct ospf_lsa *);
+void lsa_header_set (struct stream *, u_char, u_char, struct in_addr,
+ struct in_addr);
+struct ospf_neighbor *ospf_nbr_lookup_ptop (struct ospf_interface *);
/* Prototype for LSA primitive. */
struct ospf_lsa *ospf_lsa_new ();
struct ospf_lsa *ospf_lsa_dup ();
-void ospf_lsa_free (struct ospf_lsa *lsa);
+void ospf_lsa_free (struct ospf_lsa *);
struct ospf_lsa *ospf_lsa_lock (struct ospf_lsa *);
void ospf_lsa_unlock (struct ospf_lsa *);
void ospf_lsa_discard (struct ospf_lsa *);
@@ -267,17 +260,18 @@ struct ospf_lsa *ospf_summary_lsa_originate (struct prefix_ipv4 *, u_int32_t,
struct ospf_lsa *ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *,
u_int32_t,
struct ospf_area *);
-struct ospf_lsa *ospf_summary_lsa_refresh (struct ospf_lsa *);
-struct ospf_lsa *ospf_summary_asbr_lsa_refresh (struct ospf_lsa *);
+struct ospf_lsa *ospf_summary_lsa_refresh (struct ospf *, struct ospf_lsa *);
+struct ospf_lsa *ospf_summary_asbr_lsa_refresh (struct ospf *, struct ospf_lsa *);
-struct ospf_lsa *ospf_lsa_install (struct ospf_interface *, struct ospf_lsa *);
+struct ospf_lsa *ospf_lsa_install (struct ospf *,
+ struct ospf_interface *, struct ospf_lsa *);
-void ospf_external_lsa_flush (u_char, struct prefix_ipv4 *,
+void ospf_external_lsa_flush (struct ospf *, u_char, struct prefix_ipv4 *,
unsigned int, struct in_addr);
-struct in_addr ospf_get_ip_from_ifp (struct ospf_interface *oi);
+struct in_addr ospf_get_ip_from_ifp (struct ospf_interface *);
-struct ospf_lsa *ospf_external_lsa_originate (struct external_info *);
+struct ospf_lsa *ospf_external_lsa_originate (struct ospf *, struct external_info *);
int ospf_external_lsa_originate_timer (struct thread *);
struct ospf_lsa *ospf_lsa_lookup (struct ospf_area *, u_int32_t,
struct in_addr, struct in_addr);
@@ -286,24 +280,25 @@ struct ospf_lsa *ospf_lsa_lookup_by_header (struct ospf_area *,
struct lsa_header *);
int ospf_lsa_more_recent (struct ospf_lsa *, struct ospf_lsa *);
int ospf_lsa_different (struct ospf_lsa *, struct ospf_lsa *);
-void ospf_flush_self_originated_lsas_now (struct ospf *top);
+void ospf_flush_self_originated_lsas_now (struct ospf *);
-int ospf_lsa_is_self_originated (struct ospf_lsa *);
+int ospf_lsa_is_self_originated (struct ospf *, struct ospf_lsa *);
-int find_summary (struct ospf_lsa *, void *, int);
-int find_asbr_summary (struct ospf_lsa *, void *, int);
+struct ospf_lsa *ospf_lsa_lookup_by_prefix (struct ospf_lsdb *, u_char,
+ struct prefix_ipv4 *,
+ struct in_addr);
-void ospf_lsa_maxage (struct ospf_lsa *);
+void ospf_lsa_maxage (struct ospf *, struct ospf_lsa *);
u_int32_t get_metric (u_char *);
int ospf_lsa_maxage_walker (struct thread *);
-void ospf_external_lsa_refresh_default (void);
+void ospf_external_lsa_refresh_default (struct ospf *);
-void ospf_external_lsa_refresh_type (u_char, int);
-void ospf_external_lsa_refresh (struct ospf_lsa *, struct external_info *ei,
- int force);
-struct in_addr ospf_lsa_unique_id (struct ospf_lsdb *, u_char,
+void ospf_external_lsa_refresh_type (struct ospf *, u_char, int);
+void ospf_external_lsa_refresh (struct ospf *, struct ospf_lsa *,
+ struct external_info *, int);
+struct in_addr ospf_lsa_unique_id (struct ospf *, struct ospf_lsdb *, u_char,
struct prefix_ipv4 *);
void ospf_schedule_lsa_flood_area (struct ospf_area *, struct ospf_lsa *);
void ospf_schedule_lsa_flush_area (struct ospf_area *, struct ospf_lsa *);
@@ -312,15 +307,16 @@ void ospf_refresher_register_lsa (struct ospf *, struct ospf_lsa *);
void ospf_refresher_unregister_lsa (struct ospf *, struct ospf_lsa *);
int ospf_lsa_refresh_walker (struct thread *);
-void ospf_lsa_init ();
-
-void ospf_lsa_maxage_delete (struct ospf_lsa *);
+void ospf_lsa_maxage_delete (struct ospf *, struct ospf_lsa *);
-void ospf_discard_from_db (struct ospf_lsdb *, struct ospf_lsa*);
-int ospf_lsa_discard_callback (struct ospf_lsa *, void *, int);
+void ospf_discard_from_db (struct ospf *, struct ospf_lsdb *, struct ospf_lsa*);
int is_prefix_default (struct prefix_ipv4 *);
-int metric_type (u_char);
-int metric_value (u_char);
+int metric_type (struct ospf *, u_char);
+int metric_value (struct ospf *, u_char);
+
+#ifdef HAVE_NSSA
+struct in_addr ospf_get_nssa_ip (struct ospf_area *);
+#endif /* HAVE NSSA */
#endif /* _ZEBRA_OSPF_LSA_H */
diff --git a/ospfd/ospf_lsdb.h b/ospfd/ospf_lsdb.h
index 34344b3b..dba1236a 100644
--- a/ospfd/ospf_lsdb.h
+++ b/ospfd/ospf_lsdb.h
@@ -42,8 +42,9 @@ struct ospf_lsdb
};
/* Macros. */
-#define LSDB_LOOP(T,N,L) \
- for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \
+#define LSDB_LOOP(T,N,L) \
+ if ((T) != NULL) \
+ for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \
if (((L) = (N)->info))
#define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db)
diff --git a/ospfd/ospf_neighbor.h b/ospfd/ospf_neighbor.h
index f7b18742..485b548b 100644
--- a/ospfd/ospf_neighbor.h
+++ b/ospfd/ospf_neighbor.h
@@ -93,9 +93,9 @@ void ospf_nbr_free (struct ospf_neighbor *);
void ospf_nbr_delete (struct ospf_neighbor *);
int ospf_nbr_bidirectional (struct in_addr *, struct in_addr *, int);
void ospf_nbr_add_self (struct ospf_interface *);
-int ospf_nbr_count (struct route_table *, int);
+int ospf_nbr_count (struct ospf_interface *, int);
#ifdef HAVE_OPAQUE_LSA
-int ospf_opaque_capable_nbr_count (struct route_table *nbrs, int status);
+int ospf_nbr_count_opaque_capable (struct ospf_interface *);
#endif /* HAVE_OPAQUE_LSA */
struct ospf_neighbor *ospf_nbr_lookup_by_addr (struct route_table *,
struct in_addr *);
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 5d5b30c9..eee62438 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -531,7 +531,7 @@ register_opaque_info_per_type (struct ospf_opaque_functab *functab,
break;
case OSPF_OPAQUE_AS_LSA:
top = ospf_top;
- if (new->area != NULL && (top = new->area->top) == NULL)
+ if (new->area != NULL && (top = new->area->ospf) == NULL)
{
free_opaque_info_per_type ((void *) oipt);
oipt = NULL;
@@ -639,7 +639,7 @@ lookup_opaque_info_by_type (struct ospf_lsa *lsa)
break;
case OSPF_OPAQUE_AS_LSA:
top = ospf_top;
- if ((area = lsa->area) != NULL && (top = area->top) == NULL)
+ if ((area = lsa->area) != NULL && (top = area->ospf) == NULL)
{
zlog_warn ("Type-11 Opaque-LSA: Reference to OSPF is missing?");
break; /* Unlikely to happen. */
@@ -1558,7 +1558,7 @@ ospf_opaque_lsa_install (struct ospf_lsa *lsa, int rt_recalc)
}
break;
case OSPF_OPAQUE_AREA_LSA:
- if (lsa->area == NULL || (top = lsa->area->top) == NULL)
+ if (lsa->area == NULL || (top = lsa->area->ospf) == NULL)
{
/* Above conditions must have passed. */
zlog_warn ("ospf_opaque_lsa_install: Sonmething wrong?");
@@ -1567,7 +1567,7 @@ ospf_opaque_lsa_install (struct ospf_lsa *lsa, int rt_recalc)
break;
case OSPF_OPAQUE_AS_LSA:
top = ospf_top;
- if (lsa->area != NULL && (top = lsa->area->top) == NULL)
+ if (lsa->area != NULL && (top = lsa->area->ospf) == NULL)
{
/* Above conditions must have passed. */
zlog_warn ("ospf_opaque_lsa_install: Sonmething wrong?");
@@ -1589,6 +1589,7 @@ out:
void
ospf_opaque_lsa_refresh (struct ospf_lsa *lsa)
{
+ struct ospf *ospf = ospf_top;
struct ospf_opaque_functab *functab;
if ((functab = ospf_opaque_functab_lookup (lsa)) == NULL
@@ -1605,7 +1606,7 @@ ospf_opaque_lsa_refresh (struct ospf_lsa *lsa)
zlog_info ("LSA[Type%d:%s]: Flush stray Opaque-LSA", lsa->data->type, inet_ntoa (lsa->data->id));
lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
- ospf_lsa_maxage (lsa);
+ ospf_lsa_maxage (ospf, lsa);
}
else
(* functab->lsa_refresher)(lsa);
@@ -1669,7 +1670,7 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Type-10 Opaque-LSA: Invalid parameter?");
goto out;
}
- if ((top = area->top) == NULL)
+ if ((top = area->ospf) == NULL)
{
zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: AREA(%s) -> TOP?", inet_ntoa (area->area_id));
goto out;
@@ -1698,7 +1699,7 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
}
/* Fake "area" to pass "ospf" to a lookup function later. */
- dummy.top = top;
+ dummy.ospf = top;
area = &dummy;
func = ospf_opaque_type11_lsa_reoriginate_timer;
@@ -1812,7 +1813,7 @@ ospf_opaque_type9_lsa_reoriginate_timer (struct thread *t)
if (! CHECK_FLAG (top->config, OSPF_OPAQUE_CAPABLE)
|| ! ospf_if_is_enable (oi)
- || ospf_opaque_capable_nbr_count (oi->nbrs, NSM_Full) == 0)
+ || ospf_nbr_count_opaque_capable (oi) == 0)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Suspend re-origination of Type-9 Opaque-LSAs (opaque-type=%u) for a while...", oipt->opaque_type);
@@ -1852,7 +1853,7 @@ ospf_opaque_type10_lsa_reoriginate_timer (struct thread *t)
}
area = (struct ospf_area *) oipt->owner;
- if (area == NULL || (top = area->top) == NULL)
+ if (area == NULL || (top = area->ospf) == NULL)
{
zlog_warn ("ospf_opaque_type10_lsa_reoriginate_timer: Something wrong?");
goto out;
@@ -1864,7 +1865,7 @@ ospf_opaque_type10_lsa_reoriginate_timer (struct thread *t)
{
if ((oi = getdata (node)) == NULL)
continue;
- if ((n = ospf_opaque_capable_nbr_count (oi->nbrs, NSM_Full)) > 0)
+ if ((n = ospf_nbr_count_opaque_capable (oi)) > 0)
break;
}
@@ -1933,6 +1934,7 @@ extern int ospf_lsa_refresh_delay (struct ospf_lsa *); /* ospf_lsa.c */
void
ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa0)
{
+ struct ospf *ospf = ospf_top;
struct opaque_info_per_type *oipt;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
@@ -1964,10 +1966,10 @@ ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa0)
{
case OSPF_OPAQUE_LINK_LSA:
case OSPF_OPAQUE_AREA_LSA:
- ospf_ls_retransmit_delete_nbr_all (lsa->area, lsa);
+ ospf_ls_retransmit_delete_nbr_area (lsa->area, lsa);
break;
case OSPF_OPAQUE_AS_LSA:
- ospf_ls_retransmit_delete_nbr_all (NULL, lsa);
+ ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
break;
default:
zlog_warn ("ospf_opaque_lsa_refresh_schedule: Unexpected LSA-type(%u)", lsa->data->type);
@@ -2009,6 +2011,7 @@ ospf_opaque_lsa_refresh_timer (struct thread *t)
void
ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa0)
{
+ struct ospf *ospf = ospf_top;
struct opaque_info_per_type *oipt;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
@@ -2032,10 +2035,10 @@ ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa0)
{
case OSPF_OPAQUE_LINK_LSA:
case OSPF_OPAQUE_AREA_LSA:
- ospf_ls_retransmit_delete_nbr_all (lsa->area, lsa);
+ ospf_ls_retransmit_delete_nbr_area (lsa->area, lsa);
break;
case OSPF_OPAQUE_AS_LSA:
- ospf_ls_retransmit_delete_nbr_all (NULL, lsa);
+ ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
break;
default:
zlog_warn ("ospf_opaque_lsa_flush_schedule: Unexpected LSA-type(%u)", lsa->data->type);
@@ -2060,7 +2063,7 @@ ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa0)
zlog_info ("Schedule Type-%u Opaque-LSA to FLUSH: [opaque-type=%u, opaque-id=%x]", lsa->data->type, GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)), GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr)));
/* This lsa will be flushed and removed eventually. */
- ospf_lsa_maxage (lsa);
+ ospf_lsa_maxage (ospf, lsa);
out:
return;
@@ -2227,7 +2230,7 @@ ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, list lsas)
break;
case OSPF_OPAQUE_AS_LSA:
SET_FLAG (top->opaque, OPAQUE_BLOCK_TYPE_11_LSA_BIT);
- ospf_flood_through_as (NULL/*inbr*/, lsa);
+ ospf_flood_through_as (top, NULL/*inbr*/, lsa);
break;
default:
zlog_warn ("ospf_opaque_self_originated_lsa_received: Unexpected LSA-type(%u)", lsa->data->type);
@@ -2317,7 +2320,7 @@ ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, list acks)
continue;
if (! ospf_if_is_enable (oi)
- || ospf_opaque_capable_nbr_count (oi->nbrs, NSM_Full) == 0)
+ || ospf_nbr_count_opaque_capable (oi) == 0)
continue;
ospf_opaque_lsa_originate_schedule (oi, &delay);
@@ -2339,7 +2342,7 @@ ospf_opaque_type9_lsa_rxmt_nbr_check (struct ospf_interface *oi)
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Self-originated type-9 Opaque-LSAs: OI(%s): Flush completed", IF_NAME (oi));
- UNSET_FLAG (oi->area->top->opaque, OPAQUE_BLOCK_TYPE_09_LSA_BIT);
+ UNSET_FLAG (oi->area->ospf->opaque, OPAQUE_BLOCK_TYPE_09_LSA_BIT);
}
return;
}
@@ -2370,7 +2373,7 @@ ospf_opaque_type10_lsa_rxmt_nbr_check (struct ospf_area *area)
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Self-originated type-10 Opaque-LSAs: AREA(%s): Flush completed", inet_ntoa (area->area_id));
- UNSET_FLAG (area->top->opaque, OPAQUE_BLOCK_TYPE_10_LSA_BIT);
+ UNSET_FLAG (area->ospf->opaque, OPAQUE_BLOCK_TYPE_10_LSA_BIT);
}
return;
@@ -2467,7 +2470,7 @@ oi_to_top (struct ospf_interface *oi)
struct ospf *top = NULL;
struct ospf_area *area;
- if (oi == NULL || (area = oi->area) == NULL || (top = area->top) == NULL)
+ if (oi == NULL || (area = oi->area) == NULL || (top = area->ospf) == NULL)
zlog_warn ("Broken relationship for \"OI -> AREA -> OSPF\"?");
return top;
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 89878c92..9e445328 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -479,22 +479,21 @@ ospf_ls_ack_timer (struct thread *thread)
int
ospf_write (struct thread *thread)
{
+ struct ospf *ospf = THREAD_ARG (thread);
struct ospf_interface *oi;
struct ospf_packet *op;
struct sockaddr_in sa_dst;
- u_char type;
- int ret;
- int flags = 0;
struct ip iph;
struct msghdr msg;
struct iovec iov[2];
- struct ospf *top;
+ u_char type;
+ int ret;
+ int flags = 0;
listnode node;
- top = THREAD_ARG (thread);
- top->t_write = NULL;
+ ospf->t_write = NULL;
- node = listhead (top->oi_write_q);
+ node = listhead (ospf->oi_write_q);
assert (node);
oi = getdata (node);
assert (oi);
@@ -504,9 +503,9 @@ ospf_write (struct thread *thread)
assert (op);
assert (op->length >= OSPF_HEADER_SIZE);
- if (op->dst.s_addr == htonl (OSPF_ALLSPFROUTERS) ||
- op->dst.s_addr == htonl (OSPF_ALLDROUTERS))
- ospf_if_ipmulticast (top, oi->address, oi->ifp->ifindex);
+ if (op->dst.s_addr == htonl (OSPF_ALLSPFROUTERS)
+ || op->dst.s_addr == htonl (OSPF_ALLDROUTERS))
+ ospf_if_ipmulticast (ospf, oi->address, oi->ifp->ifindex);
/* Rewrite the md5 signature & update the seq */
ospf_make_md5_digest (oi, op);
@@ -526,7 +525,7 @@ ospf_write (struct thread *thread)
iph.ip_hl = sizeof (struct ip) >> 2;
iph.ip_v = IPVERSION;
- iph.ip_tos = 0;
+ iph.ip_tos = IPTOS_PREC_INTERNETCONTROL;
#if defined(__NetBSD__) || defined(__FreeBSD__)
iph.ip_len = iph.ip_hl*4 + op->length;
#else
@@ -553,7 +552,7 @@ ospf_write (struct thread *thread)
iov[1].iov_base = STREAM_DATA (op->s);
iov[1].iov_len = op->length;
- ret = sendmsg (top->fd, &msg, flags);
+ ret = sendmsg (ospf->fd, &msg, flags);
if (ret < 0)
zlog_warn ("*** sendmsg in ospf_write failed with %s", strerror (errno));
@@ -586,13 +585,13 @@ ospf_write (struct thread *thread)
if (ospf_fifo_head (oi->obuf) == NULL)
{
oi->on_write_q = 0;
- list_delete_node (top->oi_write_q, node);
+ list_delete_node (ospf->oi_write_q, node);
}
/* If packets still remain in queue, call write thread. */
- if (!list_isempty (top->oi_write_q))
- ospf_top->t_write =
- thread_add_write (master, ospf_write, top, top->fd);
+ if (!list_isempty (ospf->oi_write_q))
+ ospf->t_write =
+ thread_add_write (master, ospf_write, ospf, ospf->fd);
return 0;
}
@@ -614,7 +613,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh,
hello = (struct ospf_hello *) STREAM_PNT (s);
/* If Hello is myself, silently discard. */
- if (IPV4_ADDR_SAME (&ospfh->router_id, &ospf_top->router_id))
+ if (IPV4_ADDR_SAME (&ospfh->router_id, &oi->ospf->router_id))
return;
/* If incoming interface is passive one, ignore Hello. */
@@ -674,7 +673,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh,
#endif /* REJECT_IF_TBIT_ON */
#ifdef HAVE_OPAQUE_LSA
- if (CHECK_FLAG (ospf_top->config, OSPF_OPAQUE_CAPABLE)
+ if (CHECK_FLAG (oi->ospf->config, OSPF_OPAQUE_CAPABLE)
&& CHECK_FLAG (hello->options, OSPF_OPTION_O))
{
/*
@@ -816,7 +815,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh,
return;
}
- if (ospf_nbr_bidirectional (&ospf_top->router_id, hello->neighbors,
+ if (ospf_nbr_bidirectional (&oi->ospf->router_id, hello->neighbors,
size - OSPF_HELLO_MIN_SIZE))
{
OSPF_NSM_EVENT_EXECUTE (nbr, NSM_TwoWayReceived);
@@ -1043,7 +1042,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh,
#ifdef HAVE_OPAQUE_LSA
if (CHECK_FLAG (dd->options, OSPF_OPTION_O)
- && !CHECK_FLAG (ospf_top->config, OSPF_OPAQUE_CAPABLE))
+ && !CHECK_FLAG (oi->ospf->config, OSPF_OPAQUE_CAPABLE))
{
/*
* This node is not configured to handle O-bit, for now.
@@ -1074,7 +1073,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh,
if ((IS_SET_DD_ALL (dd->flags) == OSPF_DD_FLAG_ALL) &&
(size == OSPF_DB_DESC_MIN_SIZE))
{
- if (IPV4_ADDR_CMP (&nbr->router_id, &ospf_top->router_id) > 0)
+ if (IPV4_ADDR_CMP (&nbr->router_id, &oi->ospf->router_id) > 0)
{
/* We're Slave---obey */
zlog_warn ("Packet[DD]: Negotiation done (Slave).");
@@ -1091,7 +1090,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh,
/* Ack from the Slave */
else if (!IS_SET_DD_MS (dd->flags) && !IS_SET_DD_I (dd->flags) &&
ntohl (dd->dd_seqnum) == nbr->dd_seqnum &&
- IPV4_ADDR_CMP (&nbr->router_id, &ospf_top->router_id) < 0)
+ IPV4_ADDR_CMP (&nbr->router_id, &oi->ospf->router_id) < 0)
{
zlog_warn ("Packet[DD]: Negotiation done (Master).");
nbr->dd_flags &= ~OSPF_DD_FLAG_I;
@@ -1106,7 +1105,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh,
nbr->options = dd->options;
#ifdef HAVE_OPAQUE_LSA
- if (CHECK_FLAG (ospf_top->config, OSPF_OPAQUE_CAPABLE))
+ if (CHECK_FLAG (oi->ospf->config, OSPF_OPAQUE_CAPABLE))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Neighbor[%s] is %sOpaque-capable.",
@@ -1603,8 +1602,8 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
then take the following actions. */
if (IS_LSA_MAXAGE (lsa) && !current &&
- (ospf_nbr_count (oi->nbrs, NSM_Exchange) +
- ospf_nbr_count (oi->nbrs, NSM_Loading)) == 0)
+ (ospf_nbr_count (oi, NSM_Exchange) +
+ ospf_nbr_count (oi, NSM_Loading)) == 0)
{
/* Response Link State Acknowledgment. */
ospf_ls_ack_send (nbr, lsa);
@@ -1616,7 +1615,7 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
#ifdef HAVE_OPAQUE_LSA
if (IS_OPAQUE_LSA (lsa->data->type)
- && IPV4_ADDR_SAME (&lsa->data->adv_router, &ospf_top->router_id))
+ && IPV4_ADDR_SAME (&lsa->data->adv_router, &oi->ospf->router_id))
{
/*
* Even if initial flushing seems to be completed, there might
@@ -1669,7 +1668,7 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
(ret = ospf_lsa_more_recent (current, lsa)) < 0)
{
/* Actual flooding procedure. */
- if (ospf_flood (nbr, current, lsa) < 0) /* Trap NSSA later. */
+ if (ospf_flood (oi->ospf, nbr, current, lsa) < 0) /* Trap NSSA later. */
DISCARD_LSA (lsa, 4);
continue;
}
@@ -1966,9 +1965,9 @@ ospf_associate_packet_vl (struct interface *ifp, struct ospf_interface *oi,
struct ip *iph, struct ospf_header *ospfh)
{
struct ospf_interface *rcv_oi;
- listnode node;
struct ospf_vl_data *vl_data;
struct ospf_area *vl_area;
+ listnode node;
if (IN_MULTICAST (ntohl (iph->ip_dst.s_addr)) ||
!OSPF_IS_AREA_BACKBONE (ospfh))
@@ -1976,16 +1975,17 @@ ospf_associate_packet_vl (struct interface *ifp, struct ospf_interface *oi,
if ((rcv_oi = oi) == NULL)
{
- if ((rcv_oi = ospf_if_lookup_by_local_addr (ifp, iph->ip_dst)) == NULL)
+ if ((rcv_oi = ospf_if_lookup_by_local_addr (oi->ospf, ifp,
+ iph->ip_dst)) == NULL)
return NULL;
}
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (oi->ospf->vlinks); node; nextnode (node))
{
if ((vl_data = getdata (node)) == NULL)
continue;
- vl_area = ospf_area_lookup_by_area_id (vl_data->vl_area_id);
+ vl_area = ospf_area_lookup_by_area_id (oi->ospf, vl_data->vl_area_id);
if (!vl_area)
continue;
@@ -2188,7 +2188,7 @@ ospf_read (struct thread *thread)
{
int ret;
struct stream *ibuf;
- struct ospf *top;
+ struct ospf *ospf;
struct ospf_interface *oi;
struct ip *iph;
struct ospf_header *ospfh;
@@ -2196,18 +2196,18 @@ ospf_read (struct thread *thread)
struct interface *ifp;
/* first of all get interface pointer. */
- top = THREAD_ARG (thread);
- top->t_read = NULL;
+ ospf = THREAD_ARG (thread);
+ ospf->t_read = NULL;
/* read OSPF packet. */
- ibuf = ospf_recv_packet (top->fd, &ifp);
+ ibuf = ospf_recv_packet (ospf->fd, &ifp);
if (ibuf == NULL)
return -1;
iph = (struct ip *) STREAM_DATA (ibuf);
/* prepare for next packet. */
- top->t_read = thread_add_read (master, ospf_read, top, top->fd);
+ ospf->t_read = thread_add_read (master, ospf_read, ospf, ospf->fd);
/* IP Header dump. */
/*
@@ -2215,7 +2215,7 @@ ospf_read (struct thread *thread)
ospf_ip_header_dump (ibuf);
*/
/* Self-originated packet should be discarded silently. */
- if (ospf_if_lookup_by_local_addr (NULL, iph->ip_src))
+ if (ospf_if_lookup_by_local_addr (ospf, NULL, iph->ip_src))
{
stream_free (ibuf);
return 0;
@@ -2228,7 +2228,7 @@ ospf_read (struct thread *thread)
ospfh = (struct ospf_header *) STREAM_PNT (ibuf);
/* associate packet with ospf interface */
- oi = ospf_if_lookup_recv_interface (iph->ip_src);
+ oi = ospf_if_lookup_recv_if (ospf, iph->ip_src);
if (ifp && oi && oi->ifp != ifp)
{
zlog_warn ("Packet from [%s] received on wrong link %s",
@@ -2330,7 +2330,7 @@ ospf_make_header (int type, struct ospf_interface *oi, struct stream *s)
ospfh->version = (u_char) OSPF_VERSION;
ospfh->type = (u_char) type;
- ospfh->router_id = ospf_top->router_id;
+ ospfh->router_id = oi->ospf->router_id;
ospfh->checksum = 0;
ospfh->area_id = oi->area->area_id;
@@ -2447,19 +2447,16 @@ ospf_make_hello (struct ospf_interface *oi, struct stream *s)
/* Add neighbor seen. */
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info) != NULL)
- /* ignore 0.0.0.0 node. */
- if (nbr->router_id.s_addr != 0)
- if (nbr->state != NSM_Attempt)
- /* ignore Down neighbor. */
- if (nbr->state != NSM_Down)
- /* this is myself for DR election. */
- if (!IPV4_ADDR_SAME (&nbr->router_id, &ospf_top->router_id))
+ if ((nbr = rn->info))
+ if (nbr->router_id.s_addr != 0) /* Ignore 0.0.0.0 node. */
+ if (nbr->state != NSM_Attempt) /* Ignore Down neighbor. */
+ if (nbr->state != NSM_Down) /* This is myself for DR election. */
+ if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id))
{
/* Check neighbor is sane? */
- if (nbr->d_router.s_addr != 0 &&
- IPV4_ADDR_SAME (&nbr->d_router, &oi->address->u.prefix4) &&
- IPV4_ADDR_SAME (&nbr->bd_router, &oi->address->u.prefix4))
+ if (nbr->d_router.s_addr != 0
+ && IPV4_ADDR_SAME (&nbr->d_router, &oi->address->u.prefix4)
+ && IPV4_ADDR_SAME (&nbr->bd_router, &oi->address->u.prefix4))
flag = 1;
stream_put_ipv4 (s, nbr->router_id.s_addr);
@@ -2496,7 +2493,7 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr,
/* Set Options. */
options = OPTIONS (oi);
#ifdef HAVE_OPAQUE_LSA
- if (CHECK_FLAG (ospf_top->config, OSPF_OPAQUE_CAPABLE))
+ if (CHECK_FLAG (oi->ospf->config, OSPF_OPAQUE_CAPABLE))
{
if (IS_SET_DD_I (nbr->dd_flags)
|| CHECK_FLAG (nbr->options, OSPF_OPTION_O))
@@ -3131,6 +3128,8 @@ ospf_ls_upd_send (struct ospf_neighbor *nbr, list update, int flag)
else if ((oi->type == OSPF_IFTYPE_POINTOPOINT)
&& (flag == OSPF_SEND_PACKET_INDIRECT))
p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS);
+ else if (oi->type == OSPF_IFTYPE_POINTOMULTIPOINT)
+ p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS);
else
p.prefix.s_addr = htonl (OSPF_ALLDROUTERS);
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index 96f7531f..cc3b6787 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -206,22 +206,22 @@ ospf_route_delete_uniq (struct route_table *rt, struct route_table *cmprt)
/* Install routes to table. */
void
-ospf_route_install (struct route_table *rt)
+ospf_route_install (struct ospf *ospf, struct route_table *rt)
{
struct route_node *rn;
struct ospf_route *or;
/* rt contains new routing table, new_table contains an old one.
updating pointers */
- if (ospf_top->old_table)
- ospf_route_table_free (ospf_top->old_table);
-
- ospf_top->old_table = ospf_top->new_table;
- ospf_top->new_table = rt;
+ if (ospf->old_table)
+ ospf_route_table_free (ospf->old_table);
+
+ ospf->old_table = ospf->new_table;
+ ospf->new_table = rt;
/* Delete old routes. */
- if (ospf_top->old_table)
- ospf_route_delete_uniq (ospf_top->old_table, rt);
+ if (ospf->old_table)
+ ospf_route_delete_uniq (ospf->old_table, rt);
/* Install new routes. */
for (rn = route_top (rt); rn; rn = route_next (rn))
@@ -229,12 +229,12 @@ ospf_route_install (struct route_table *rt)
{
if (or->type == OSPF_DESTINATION_NETWORK)
{
- if (! ospf_route_match_same (ospf_top->old_table,
+ if (! ospf_route_match_same (ospf->old_table,
(struct prefix_ipv4 *)&rn->p, or))
ospf_zebra_add ((struct prefix_ipv4 *) &rn->p, or);
}
else if (or->type == OSPF_DESTINATION_DISCARD)
- if (! ospf_route_match_same (ospf_top->old_table,
+ if (! ospf_route_match_same (ospf->old_table,
(struct prefix_ipv4 *) &rn->p, or))
ospf_zebra_add_discard ((struct prefix_ipv4 *) &rn->p);
}
@@ -595,7 +595,7 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_intra_add_stub(): this network is on this router");
- if ((oi = ospf_if_lookup_by_prefix (&p)))
+ if ((oi = ospf_if_lookup_by_prefix (area->ospf, &p)))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_intra_add_stub(): the interface is %s",
@@ -676,12 +676,14 @@ ospf_route_table_dump (struct route_table *rt)
void
ospf_terminate ()
{
- if (ospf_top)
+ struct ospf *ospf = ospf_top;
+
+ if (ospf)
{
- if (ospf_top->new_table)
- ospf_route_delete (ospf_top->new_table);
- if (ospf_top->old_external_route)
- ospf_route_delete (ospf_top->old_external_route);
+ if (ospf->new_table)
+ ospf_route_delete (ospf->new_table);
+ if (ospf->old_external_route)
+ ospf_route_delete (ospf->old_external_route);
}
}
@@ -690,7 +692,8 @@ ospf_terminate ()
o The other paths, intra-area backbone paths and inter-area paths,
are of equal preference. */
int
-ospf_asbr_route_cmp (struct ospf_route *r1, struct ospf_route *r2)
+ospf_asbr_route_cmp (struct ospf *ospf, struct ospf_route *r1,
+ struct ospf_route *r2)
{
u_char r1_type, r2_type;
@@ -698,7 +701,7 @@ ospf_asbr_route_cmp (struct ospf_route *r1, struct ospf_route *r2)
r2_type = r2->path_type;
/* If RFC1583Compat flag is on -- all paths are equal. */
- if (CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE))
+ if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
return 0;
/* r1/r2 itself is backbone, and it's Inter-area path. */
@@ -715,7 +718,8 @@ ospf_asbr_route_cmp (struct ospf_route *r1, struct ospf_route *r2)
ret == 0 -- r1 and r2 are the same.
ret > 0 -- r2 is better. */
int
-ospf_route_cmp (struct ospf_route *r1, struct ospf_route *r2)
+ospf_route_cmp (struct ospf *ospf, struct ospf_route *r1,
+ struct ospf_route *r2)
{
int ret = 0;
@@ -732,9 +736,9 @@ ospf_route_cmp (struct ospf_route *r1, struct ospf_route *r2)
case OSPF_PATH_INTER_AREA:
break;
case OSPF_PATH_TYPE1_EXTERNAL:
- if (!CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE))
+ if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
- ret = ospf_asbr_route_cmp (r1->u.ext.asbr, r2->u.ext.asbr);
+ ret = ospf_asbr_route_cmp (ospf, r1->u.ext.asbr, r2->u.ext.asbr);
if (ret != 0)
return ret;
}
@@ -743,9 +747,9 @@ ospf_route_cmp (struct ospf_route *r1, struct ospf_route *r2)
if ((ret = (r1->u.ext.type2_cost - r2->u.ext.type2_cost)))
return ret;
- if (!CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE))
+ if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
- ret = ospf_asbr_route_cmp (r1->u.ext.asbr, r2->u.ext.asbr);
+ ret = ospf_asbr_route_cmp (ospf, r1->u.ext.asbr, r2->u.ext.asbr);
if (ret != 0)
return ret;
}
diff --git a/ospfd/ospf_route.h b/ospfd/ospf_route.h
index 81f59c48..4222f528 100644
--- a/ospfd/ospf_route.h
+++ b/ospfd/ospf_route.h
@@ -124,14 +124,14 @@ struct ospf_route
};
struct ospf_path *ospf_path_new ();
-void ospf_path_free (struct ospf_path *op);
+void ospf_path_free (struct ospf_path *);
struct ospf_path *ospf_path_lookup (list, struct ospf_path *);
struct ospf_route *ospf_route_new ();
-void ospf_route_free (struct ospf_route *or);
-void ospf_route_delete (struct route_table *rt);
-void ospf_route_table_free (struct route_table *rt);
+void ospf_route_free (struct ospf_route *);
+void ospf_route_delete (struct route_table *);
+void ospf_route_table_free (struct route_table *);
-void ospf_route_install (struct route_table *);
+void ospf_route_install (struct ospf *, struct route_table *);
void ospf_route_table_dump (struct route_table *);
void ospf_intra_add_router (struct route_table *, struct vertex *,
@@ -143,7 +143,7 @@ void ospf_intra_add_transit (struct route_table *, struct vertex *,
void ospf_intra_add_stub (struct route_table *, struct router_lsa_link *,
struct vertex *, struct ospf_area *);
-int ospf_route_cmp (struct ospf_route *, struct ospf_route *);
+int ospf_route_cmp (struct ospf *, struct ospf_route *, struct ospf_route *);
void ospf_route_copy_nexthops (struct ospf_route *, list);
void ospf_route_copy_nexthops_from_vertex (struct ospf_route *,
struct vertex * );
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index a2b257fa..a4d05a13 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -43,10 +43,11 @@
void
ospf_route_map_update (char *name)
{
+ struct ospf *ospf = ospf_top;
int type;
/* If OSPF instatnce does not exist, return right now. */
- if (!ospf_top)
+ if (ospf == NULL)
return;
/* Update route-map */
@@ -64,7 +65,7 @@ ospf_route_map_update (char *name)
if (old == NULL && ROUTEMAP (type) == NULL)
continue;
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
}
}
}
@@ -72,10 +73,11 @@ ospf_route_map_update (char *name)
void
ospf_route_map_event (route_map_event_t event, char *name)
{
+ struct ospf *ospf = ospf_top;
int type;
/* If OSPF instatnce does not exist, return right now. */
- if (!ospf_top)
+ if (ospf == NULL)
return;
/* Update route-map. */
@@ -84,7 +86,7 @@ ospf_route_map_event (route_map_event_t event, char *name)
if (ROUTEMAP_NAME (type) && ROUTEMAP (type) &&
!strcmp (ROUTEMAP_NAME (type), name))
{
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
}
}
}
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 6187977e..389fd73c 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -493,15 +493,15 @@ struct variable ospf_variables[] =
/* The administrative status of OSPF. When OSPF is enbled on at least
one interface return 1. */
int
-ospf_admin_stat ()
+ospf_admin_stat (struct ospf *ospf)
{
listnode node;
struct ospf_interface *oi;
- if (! ospf_top)
+ if (ospf == NULL)
return 0;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
oi = getdata (node);
@@ -515,6 +515,8 @@ static u_char *
ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
+ struct ospf *ospf = ospf_top;
+
/* Check whether the instance identifier is valid */
if (smux_header_generic (v, name, length, exact, var_len, write_method)
== MATCH_FAILED)
@@ -525,14 +527,14 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
{
case OSPFROUTERID: /* 1 */
/* Router-ID of this OSPF instance. */
- if (ospf_top)
- return SNMP_IPADDRESS (ospf_top->router_id);
+ if (ospf)
+ return SNMP_IPADDRESS (ospf->router_id);
else
return SNMP_IPADDRESS (ospf_empty_addr);
break;
case OSPFADMINSTAT: /* 2 */
/* The administrative status of OSPF in the router. */
- if (ospf_admin_stat ())
+ if (ospf_admin_stat (ospf))
return SNMP_INTEGER (OSPF_STATUS_ENABLED);
else
return SNMP_INTEGER (OSPF_STATUS_DISABLED);
@@ -543,22 +545,22 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
break;
case OSPFAREABDRRTRSTATUS: /* 4 */
/* Area Border router status. */
- if (ospf_top && CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ABR))
+ if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
return SNMP_INTEGER (SNMP_TRUE);
else
return SNMP_INTEGER (SNMP_FALSE);
break;
case OSPFASBDRRTRSTATUS: /* 5 */
/* AS Border router status. */
- if (ospf_top && CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ASBR))
+ if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
return SNMP_INTEGER (SNMP_TRUE);
else
return SNMP_INTEGER (SNMP_FALSE);
break;
case OSPFEXTERNLSACOUNT: /* 6 */
/* External LSA counts. */
- if (ospf_top)
- return SNMP_INTEGER (ospf_lsdb_count_all (ospf_top->lsdb));
+ if (ospf)
+ return SNMP_INTEGER (ospf_lsdb_count_all (ospf->lsdb));
else
return SNMP_INTEGER (0);
break;
@@ -572,16 +574,16 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
break;
case OSPFORIGINATENEWLSAS: /* 9 */
/* The number of new link-state advertisements. */
- if (ospf_top)
- return SNMP_INTEGER (ospf_top->lsa_originate_count);
+ if (ospf)
+ return SNMP_INTEGER (ospf->lsa_originate_count);
else
return SNMP_INTEGER (0);
break;
case OSPFRXNEWLSAS: /* 10 */
/* The number of link-state advertisements received determined
to be new instantiations. */
- if (ospf_top)
- return SNMP_INTEGER (ospf_top->rx_lsa_count);
+ if (ospf)
+ return SNMP_INTEGER (ospf->rx_lsa_count);
else
return SNMP_INTEGER (0);
break;
@@ -609,7 +611,7 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
}
struct ospf_area *
-ospf_area_lookup_next (struct in_addr *area_id, int first)
+ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first)
{
struct ospf_area *area;
listnode node;
@@ -619,7 +621,7 @@ ospf_area_lookup_next (struct in_addr *area_id, int first)
if (first)
{
- node = listhead (ospf_top->areas);
+ node = listhead (ospf->areas);
if (node)
{
area = getdata (node);
@@ -628,7 +630,7 @@ ospf_area_lookup_next (struct in_addr *area_id, int first)
}
return NULL;
}
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -645,10 +647,11 @@ struct ospf_area *
ospfAreaLookup (struct variable *v, oid name[], size_t *length,
struct in_addr *addr, int exact)
{
- int len;
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
+ int len;
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
if (exact)
@@ -659,7 +662,7 @@ ospfAreaLookup (struct variable *v, oid name[], size_t *length,
oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr);
- area = ospf_area_lookup_by_area_id (*addr);
+ area = ospf_area_lookup_by_area_id (ospf, *addr);
return area;
}
@@ -671,7 +674,7 @@ ospfAreaLookup (struct variable *v, oid name[], size_t *length,
oid2in_addr (name + v->namelen, len, addr);
- area = ospf_area_lookup_next (addr, len == 0 ? 1 : 0);
+ area = ospf_area_lookup_next (ospf, addr, len == 0 ? 1 : 0);
if (area == NULL)
return NULL;
@@ -776,8 +779,9 @@ struct ospf_area *
ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
struct in_addr *addr, int exact)
{
- int len;
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
+ int len;
if (! ospf_top)
return NULL;
@@ -795,7 +799,7 @@ ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr);
- area = ospf_area_lookup_by_area_id (*addr);
+ area = ospf_area_lookup_by_area_id (ospf, *addr);
if (area->external_routing == OSPF_AREA_STUB)
return area;
@@ -903,6 +907,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
struct in_addr *area_id, u_char *type,
struct in_addr *ls_id, struct in_addr *router_id, int exact)
{
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
struct ospf_lsa *lsa;
int len;
@@ -926,7 +931,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
/* Lookup area first. */
oid2in_addr (offset, IN_ADDR_SIZE, area_id);
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf, *area_id);
if (! area)
return NULL;
offset += IN_ADDR_SIZE;
@@ -959,9 +964,9 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
/* First we search area. */
if (len == IN_ADDR_SIZE)
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf, *area_id);
else
- area = ospf_area_lookup_next (area_id, len == 0 ? 1 : 0);
+ area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0);
if (area == NULL)
return NULL;
@@ -1035,7 +1040,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
return lsa;
}
}
- while ((area = ospf_area_lookup_next (area_id, 0)) != NULL);
+ while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL);
}
return NULL;
}
@@ -1113,6 +1118,7 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
oid *offset;
int offsetlen;
int len;
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
struct ospf_area_range *range;
struct prefix_ipv4 p;
@@ -1131,7 +1137,7 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
/* Lookup area first. */
oid2in_addr (offset, IN_ADDR_SIZE, area_id);
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf, *area_id);
if (! area)
return NULL;
@@ -1157,9 +1163,9 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
/* First we search area. */
if (len == IN_ADDR_SIZE)
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf,*area_id);
else
- area = ospf_area_lookup_next (area_id, len == 0 ? 1 : 0);
+ area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0);
if (area == NULL)
return NULL;
@@ -1194,7 +1200,7 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
return range;
}
}
- while ((area = ospf_area_lookup_next (area_id, 0)) != NULL);
+ while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL);
}
return NULL;
}
@@ -1207,9 +1213,10 @@ ospfAreaRangeEntry (struct variable *v, oid *name, size_t *length, int exact,
struct in_addr area_id;
struct in_addr range_net;
struct in_addr mask;
+ struct ospf *ospf = ospf_top;
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
memset (&area_id, 0, IN_ADDR_SIZE);
@@ -1255,8 +1262,9 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
{
int len;
struct ospf_nbr_nbma *nbr_nbma;
+ struct ospf *ospf = ospf_top;
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
if (exact)
@@ -1271,7 +1279,7 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
oid2in_addr (name + v->namelen, IN_ADDR_SIZE, addr);
- nbr_nbma = ospf_nbr_nbma_lookup (ospf_top, *addr);
+ nbr_nbma = ospf_nbr_nbma_lookup (ospf, *addr);
return nbr_nbma;
}
@@ -1283,7 +1291,7 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
oid2in_addr (name + v->namelen, len, addr);
- nbr_nbma = ospf_nbr_nbma_lookup_next (addr, len == 0 ? 1 : 0);
+ nbr_nbma = ospf_nbr_nbma_lookup_next (ospf, addr, len == 0 ? 1 : 0);
if (nbr_nbma == NULL)
return NULL;
@@ -1307,9 +1315,10 @@ ospfHostEntry (struct variable *v, oid *name, size_t *length, int exact,
struct ospf_nbr_nbma *nbr_nbma;
struct ospf_interface *oi;
struct in_addr addr;
+ struct ospf *ospf = ospf_top;
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
memset (&addr, 0, sizeof (struct in_addr));
@@ -1597,19 +1606,20 @@ ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact,
unsigned int ifindex;
struct in_addr ifaddr;
struct ospf_interface *oi;
+ struct ospf *ospf = ospf_top;
ifindex = 0;
memset (&ifaddr, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
ifp = ospfIfLookup (v, name, length, &ifaddr, &ifindex, exact);
if (ifp == NULL)
return NULL;
- oi = ospf_if_lookup_by_local_addr (ifp, ifaddr);
+ oi = ospf_if_lookup_by_local_addr (ospf, ifp, ifaddr);
if (oi == NULL)
return NULL;
@@ -1768,19 +1778,20 @@ ospfIfMetricEntry (struct variable *v, oid *name, size_t *length, int exact,
unsigned int ifindex;
struct in_addr ifaddr;
struct ospf_interface *oi;
+ struct ospf *ospf = ospf_top;
ifindex = 0;
memset (&ifaddr, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
ifp = ospfIfMetricLookup (v, name, length, &ifaddr, &ifindex, exact);
if (ifp == NULL)
return NULL;
- oi = ospf_if_lookup_by_local_addr (ifp, ifaddr);
+ oi = ospf_if_lookup_by_local_addr (ospf, ifp, ifaddr);
if (oi == NULL)
return NULL;
@@ -2022,14 +2033,15 @@ ospfVirtIfEntry (struct variable *v, oid *name, size_t *length, int exact,
}
struct ospf_neighbor *
-ospf_snmp_nbr_lookup (struct in_addr *nbr_addr, unsigned int *ifindex)
+ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
+ unsigned int *ifindex)
{
struct listnode *nn;
struct ospf_interface *oi;
struct ospf_neighbor *nbr;
struct route_node *rn;
- LIST_LOOP (ospf_top->oiflist, oi, nn)
+ LIST_LOOP (ospf->oiflist, oi, nn)
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
@@ -2056,8 +2068,9 @@ ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, unsigned int *ifindex,
struct ospf_neighbor *nbr;
struct route_node *rn;
struct ospf_neighbor *min = NULL;
+ struct ospf *ospf = ospf_top;
- LIST_LOOP (ospf_top->oiflist, oi, nn)
+ LIST_LOOP (ospf->oiflist, oi, nn)
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
@@ -2097,6 +2110,7 @@ ospfNbrLookup (struct variable *v, oid *name, size_t *length,
int len;
int first;
struct ospf_neighbor *nbr;
+ struct ospf *ospf = ospf_top;
if (exact)
{
@@ -2106,7 +2120,7 @@ ospfNbrLookup (struct variable *v, oid *name, size_t *length,
oid2in_addr (name + v->namelen, IN_ADDR_SIZE, nbr_addr);
*ifindex = name[v->namelen + IN_ADDR_SIZE];
- return ospf_snmp_nbr_lookup (nbr_addr, ifindex);
+ return ospf_snmp_nbr_lookup (ospf, nbr_addr, ifindex);
}
else
{
@@ -2207,12 +2221,13 @@ ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
struct ospf_vl_data *vl_data;
struct in_addr area_id;
struct in_addr neighbor;
+ struct ospf *ospf = ospf_top;
memset (&area_id, 0, sizeof (struct in_addr));
memset (&neighbor, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
vl_data = ospfVirtIfLookup (v, name, length, &area_id, &neighbor, exact);
@@ -2263,6 +2278,7 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
u_char lsa_type;
int len;
struct ospf_lsa *lsa;
+ struct ospf *ospf = ospf_top;
if (exact)
{
@@ -2285,7 +2301,7 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
/* Router ID. */
oid2in_addr (offset, IN_ADDR_SIZE, router_id);
- return ospf_lsdb_lookup_by_id (ospf_top->lsdb, *type, *ls_id, *router_id);
+ return ospf_lsdb_lookup_by_id (ospf->lsdb, *type, *ls_id, *router_id);
}
else
{
@@ -2319,7 +2335,7 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
oid2in_addr (offset, len, router_id);
- lsa = ospf_lsdb_lookup_by_id_next (ospf_top->lsdb, *type, *ls_id,
+ lsa = ospf_lsdb_lookup_by_id_next (ospf->lsdb, *type, *ls_id,
*router_id, first);
if (lsa)
@@ -2351,13 +2367,14 @@ ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
u_char type;
struct in_addr ls_id;
struct in_addr router_id;
+ struct ospf *ospf = ospf_top;
type = OSPF_AS_EXTERNAL_LSA;
memset (&ls_id, 0, sizeof (struct in_addr));
memset (&router_id, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
lsa = ospfExtLsdbLookup (v, name, length, &type, &ls_id, &router_id, exact);
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index d6254717..759304c8 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -365,18 +365,42 @@ ospf_nexthop_calculation (struct ospf_area *area,
if (l->m[0].type == LSA_LINK_TYPE_POINTOPOINT)
{
- while ((l2 = ospf_get_next_link (w, v, l2)))
+ /* Check for PtMP, signified by PtP link V->W
+ with link_data our PtMP interface. */
+ oi = ospf_if_is_configured (area->ospf, &l->link_data);
+ if (oi && oi->type == OSPF_IFTYPE_POINTOMULTIPOINT)
{
- oi = ospf_if_is_configured (&(l2->link_data));
+ struct prefix_ipv4 la;
+ la.prefixlen = oi->address->prefixlen;
- if (oi == NULL)
- continue;
-
- if (! IPV4_ADDR_SAME (&oi->address->u.prefix4,
- &l->link_data))
- continue;
-
- break;
+ /* We link to them on PtMP interface
+ - find the interface on w */
+ while ((l2 = ospf_get_next_link (w, v, l2)))
+ {
+ la.prefix = l2->link_data;
+
+ if (prefix_cmp ((struct prefix *)&la,
+ oi->address) == 0)
+ /* link_data is on our PtMP network */
+ break;
+ }
+ }
+ else
+ {
+ while ((l2 = ospf_get_next_link (w, v, l2)))
+ {
+ oi = ospf_if_is_configured (area->ospf,
+ &(l2->link_data));
+
+ if (oi == NULL)
+ continue;
+
+ if (!IPV4_ADDR_SAME (&oi->address->u.prefix4,
+ &l->link_data))
+ continue;
+
+ break;
+ }
}
if (oi && l2)
@@ -393,7 +417,7 @@ ospf_nexthop_calculation (struct ospf_area *area,
{
while ((l = ospf_get_next_link (v, w, l)))
{
- oi = ospf_if_is_configured (&(l->link_data));
+ oi = ospf_if_is_configured (area->ospf, &(l->link_data));
if (oi)
{
nh = vertex_nexthop_new (v);
@@ -974,7 +998,7 @@ ospf_spf_calculate (struct ospf_area *area, struct route_table *new_table,
/* Increment SPF Calculation Counter. */
area->spf_calculation++;
- ospf_top->ts_spf = time (NULL);
+ area->ospf->ts_spf = time (NULL);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_spf_calculate: Stop");
@@ -982,32 +1006,30 @@ ospf_spf_calculate (struct ospf_area *area, struct route_table *new_table,
/* Timer for SPF calculation. */
int
-ospf_spf_calculate_timer (struct thread *t)
+ospf_spf_calculate_timer (struct thread *thread)
{
+ struct ospf *ospf = THREAD_ARG (thread);
struct route_table *new_table, *new_rtrs;
- struct ospf *ospf;
- /* struct ospf_area *area; */
listnode node;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("SPF: Timer (SPF calculation expire)");
- ospf = THREAD_ARG (t);
ospf->t_spf_calc = NULL;
/* Allocate new table tree. */
new_table = route_table_init ();
new_rtrs = route_table_init ();
- ospf_vl_unapprove ();
+ ospf_vl_unapprove (ospf);
/* Calculate SPF for each area. */
for (node = listhead (ospf->areas); node; node = nextnode (node))
ospf_spf_calculate (node->data, new_table, new_rtrs);
- ospf_vl_shut_unapproved ();
+ ospf_vl_shut_unapproved (ospf);
- ospf_ia_routing (new_table, new_rtrs);
+ ospf_ia_routing (ospf, new_table, new_rtrs);
ospf_prune_unreachable_networks (new_table);
ospf_prune_unreachable_routers (new_rtrs);
@@ -1017,26 +1039,26 @@ ospf_spf_calculate_timer (struct thread *t)
/* If new Router Route is installed,
then schedule re-calculate External routes. */
if (1)
- ospf_ase_calculate_schedule ();
+ ospf_ase_calculate_schedule (ospf);
- ospf_ase_calculate_timer_add ();
+ ospf_ase_calculate_timer_add (ospf);
/* Update routing table. */
- ospf_route_install (new_table);
+ ospf_route_install (ospf, new_table);
/* Update ABR/ASBR routing table */
- if (ospf_top->old_rtrs)
+ if (ospf->old_rtrs)
{
/* old_rtrs's node holds linked list of ospf_route. --kunihiro. */
- /* ospf_route_delete (ospf_top->old_rtrs); */
- ospf_rtrs_free (ospf_top->old_rtrs);
+ /* ospf_route_delete (ospf->old_rtrs); */
+ ospf_rtrs_free (ospf->old_rtrs);
}
- ospf_top->old_rtrs = ospf_top->new_rtrs;
- ospf_top->new_rtrs = new_rtrs;
+ ospf->old_rtrs = ospf->new_rtrs;
+ ospf->new_rtrs = new_rtrs;
if (OSPF_IS_ABR)
- ospf_abr_task (new_table, new_rtrs);
+ ospf_abr_task (ospf);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("SPF: calculation complete");
@@ -1047,7 +1069,7 @@ ospf_spf_calculate_timer (struct thread *t)
/* Add schedule for SPF calculation. To avoid frequenst SPF calc, we
set timer for SPF calc. */
void
-ospf_spf_calculate_schedule ()
+ospf_spf_calculate_schedule (struct ospf *ospf)
{
time_t ht, delay;
@@ -1055,34 +1077,34 @@ ospf_spf_calculate_schedule ()
zlog_info ("SPF: calculation timer scheduled");
/* OSPF instance does not exist. */
- if (!ospf_top)
+ if (ospf == NULL)
return;
/* SPF calculation timer is already scheduled. */
- if (ospf_top->t_spf_calc)
+ if (ospf->t_spf_calc)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("SPF: calculation timer is already scheduled: %p",
- ospf_top->t_spf_calc);
+ ospf->t_spf_calc);
return;
}
- ht = time (NULL) - ospf_top->ts_spf;
+ ht = time (NULL) - ospf->ts_spf;
/* Get SPF calculation delay time. */
- if (ht < ospf_top->spf_holdtime)
+ if (ht < ospf->spf_holdtime)
{
- if (ospf_top->spf_holdtime - ht < ospf_top->spf_delay)
- delay = ospf_top->spf_delay;
+ if (ospf->spf_holdtime - ht < ospf->spf_delay)
+ delay = ospf->spf_delay;
else
- delay = ospf_top->spf_holdtime - ht;
+ delay = ospf->spf_holdtime - ht;
}
else
- delay = ospf_top->spf_delay;
+ delay = ospf->spf_delay;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("SPF: calculation timer delay = %ld", delay);
- ospf_top->t_spf_calc =
- thread_add_timer (master, ospf_spf_calculate_timer, ospf_top, delay);
+ ospf->t_spf_calc =
+ thread_add_timer (master, ospf_spf_calculate_timer, ospf, delay);
}
diff --git a/ospfd/ospf_spf.h b/ospfd/ospf_spf.h
index 7fe682ee..e71224bd 100644
--- a/ospfd/ospf_spf.h
+++ b/ospfd/ospf_spf.h
@@ -44,7 +44,7 @@ struct vertex_nexthop
struct vertex *parent;
};
-void ospf_spf_calculate_schedule ();
+void ospf_spf_calculate_schedule (struct ospf *);
void ospf_rtrs_free (struct route_table *);
/* void ospf_spf_calculate_timer_add (); */
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index aedac32a..2129e354 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -414,8 +414,8 @@ set_linkparams_link_id (struct ospf_interface *oi, struct mpls_te_link *lp)
{
case OSPF_IFTYPE_POINTOPOINT:
/* Take the router ID of the neighbor. */
- if (((nbr = ospf_nbr_lookup_ptop (oi->nbrs, oi->area->top->router_id)))
- && (nbr->state == NSM_Full))
+ if ((nbr = ospf_nbr_lookup_ptop (oi))
+ && nbr->state == NSM_Full)
{
lp->link_id.value = nbr->router_id;
done = 1;
@@ -429,7 +429,7 @@ set_linkparams_link_id (struct ospf_interface *oi, struct mpls_te_link *lp)
if (nbr->state == NSM_Full
|| (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))
- && ospf_nbr_count (oi->nbrs, NSM_Full) > 0))
+ && ospf_nbr_count (oi, NSM_Full) > 0))
{
lp->link_id.value = DR (oi);
done = 1;
@@ -628,7 +628,7 @@ ospf_mpls_te_ism_change (struct ospf_interface *oi, int old_state)
zlog_warn ("ospf_mpls_te_ism_change: Cannot get linkparams from OI(%s)?", IF_NAME (oi));
goto out;
}
- if (oi->area == NULL || oi->area->top == NULL)
+ if (oi->area == NULL || oi->area->ospf == NULL)
{
zlog_warn ("ospf_mpls_te_ism_change: Cannot refer to OSPF from OI(%s)?",
IF_NAME (oi));
@@ -891,7 +891,7 @@ ospf_mpls_te_lsa_new (struct ospf_area *area, struct mpls_te_link *lp)
zlog_info ("LSA[Type%d:%s]: Create an Opaque-LSA/MPLS-TE instance", lsa_type, inet_ntoa (lsa_id));
/* Set opaque-LSA header fields. */
- lsa_header_set (s, options, lsa_type, lsa_id);
+ lsa_header_set (s, options, lsa_type, lsa_id, area->ospf->router_id);
/* Set opaque-LSA body fields. */
ospf_mpls_te_lsa_body_set (s, lp);
@@ -939,7 +939,7 @@ ospf_mpls_te_lsa_originate1 (struct ospf_area *area, struct mpls_te_link *lp)
}
/* Install this LSA into LSDB. */
- if (ospf_lsa_install (NULL/*oi*/, new) == NULL)
+ if (ospf_lsa_install (area->ospf, NULL/*oi*/, new) == NULL)
{
zlog_warn ("ospf_mpls_te_lsa_originate1: ospf_lsa_install() ?");
ospf_lsa_free (new);
@@ -950,7 +950,7 @@ ospf_mpls_te_lsa_originate1 (struct ospf_area *area, struct mpls_te_link *lp)
lp->flags |= LPFLG_LSA_ENGAGED;
/* Update new LSA origination count. */
- area->top->lsa_originate_count++;
+ area->ospf->lsa_originate_count++;
/* Flood new LSA through area. */
ospf_flood_through_area (area, NULL/*nbr*/, new);
@@ -1059,7 +1059,7 @@ ospf_mpls_te_lsa_refresh (struct ospf_lsa *lsa)
/* Install this LSA into LSDB. */
/* Given "lsa" will be freed in the next function. */
- if (ospf_lsa_install (NULL/*oi*/, new) == NULL)
+ if (ospf_lsa_install (area->ospf, NULL/*oi*/, new) == NULL)
{
zlog_warn ("ospf_mpls_te_lsa_refresh: ospf_lsa_install() ?");
ospf_lsa_free (new);
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 73215fa5..2bb24b8c 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -199,8 +199,9 @@ DEFUN (ospf_router_id,
"router-id for the OSPF process\n"
"OSPF router-id in IP address format\n")
{
- int ret;
+ struct ospf *ospf = vty->index;
struct in_addr router_id;
+ int ret;
ret = inet_aton (argv[0], &router_id);
if (!ret)
@@ -209,11 +210,10 @@ DEFUN (ospf_router_id,
return CMD_WARNING;
}
- /* ospf_top->router_id = router_id; */
- ospf_top->router_id_static = router_id;
+ ospf->router_id_static = router_id;
- if (ospf_top->t_router_id_update == NULL)
- ospf_top->t_router_id_update =
+ if (ospf->t_router_id_update == NULL)
+ ospf->t_router_id_update =
thread_add_timer (master, ospf_router_id_update_timer, NULL,
OSPF_ROUTER_ID_UPDATE_DELAY);
@@ -233,9 +233,11 @@ DEFUN (no_ospf_router_id,
"OSPF specific commands\n"
"router-id for the OSPF process\n")
{
- ospf_top->router_id_static.s_addr = 0;
+ struct ospf *ospf = vty->index;
+
+ ospf->router_id_static.s_addr = 0;
- ospf_router_id_update ();
+ ospf_router_id_update (ospf);
return CMD_SUCCESS;
}
@@ -647,7 +649,7 @@ ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
}
struct ospf_vl_data *
-ospf_find_vl_data (struct ospf_vl_config_data *vl_config)
+ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
{
struct ospf_area *area;
struct ospf_vl_data *vl_data;
@@ -664,7 +666,7 @@ ospf_find_vl_data (struct ospf_vl_config_data *vl_config)
VTY_NEWLINE);
return NULL;
}
- area = ospf_area_get (area_id, vl_config->format);
+ area = ospf_area_get (ospf, area_id, vl_config->format);
if (area->external_routing != OSPF_AREA_DEFAULT)
{
@@ -694,9 +696,9 @@ ospf_find_vl_data (struct ospf_vl_config_data *vl_config)
vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
if (vl_data->vl_oi == NULL)
{
- vl_data->vl_oi = ospf_vl_new (vl_data);
- ospf_vl_add (vl_data);
- ospf_spf_calculate_schedule ();
+ vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
+ ospf_vl_add (ospf, vl_data);
+ ospf_spf_calculate_schedule (ospf);
}
}
return vl_data;
@@ -800,12 +802,12 @@ ospf_vl_set_timers (struct ospf_vl_data *vl_data,
/* The business end of all of the above */
int
-ospf_vl_set (struct ospf_vl_config_data *vl_config)
+ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
{
struct ospf_vl_data *vl_data;
int ret;
- vl_data = ospf_find_vl_data (vl_config);
+ vl_data = ospf_find_vl_data (ospf, vl_config);
if (!vl_data)
return CMD_WARNING;
@@ -872,6 +874,7 @@ DEFUN (area_vlink,
"area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
VLINK_HELPSTR_IPADDR)
{
+ struct ospf *ospf = vty->index;
struct ospf_vl_config_data vl_config;
char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
char md5_key[OSPF_AUTH_MD5_SIZE+1];
@@ -900,7 +903,7 @@ DEFUN (area_vlink,
{
/* Thats all folks! - BUGS B. strikes again!!!*/
- return ospf_vl_set (&vl_config);
+ return ospf_vl_set (ospf, &vl_config);
}
/* Deal with other parameters */
@@ -996,7 +999,7 @@ DEFUN (area_vlink,
/* Action configuration */
- return ospf_vl_set (&vl_config);
+ return ospf_vl_set (ospf, &vl_config);
}
@@ -1006,6 +1009,7 @@ DEFUN (no_area_vlink,
NO_STR
VLINK_HELPSTR_IPADDR)
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct ospf_vl_config_data vl_config;
struct ospf_vl_data *vl_data = NULL;
@@ -1022,7 +1026,7 @@ DEFUN (no_area_vlink,
return CMD_WARNING;
}
- area = ospf_area_lookup_by_area_id (vl_config.area_id);
+ area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
if (!area)
{
vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
@@ -1042,9 +1046,9 @@ DEFUN (no_area_vlink,
/* Basic VLink no command */
/* Thats all folks! - BUGS B. strikes again!!!*/
if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
- ospf_vl_delete (vl_data);
+ ospf_vl_delete (ospf, vl_data);
- ospf_area_check_free (vl_config.area_id);
+ ospf_area_check_free (ospf, vl_config.area_id);
return CMD_SUCCESS;
}
@@ -1054,7 +1058,6 @@ DEFUN (no_area_vlink,
/* Deal with other parameters */
for (i=2; i < argc; i++)
{
-
/* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
switch (argv[i][0])
@@ -1113,7 +1116,7 @@ DEFUN (no_area_vlink,
/* Action configuration */
- return ospf_vl_set (&vl_config);
+ return ospf_vl_set (ospf, &vl_config);
}
ALIAS (area_vlink,
@@ -1320,6 +1323,7 @@ DEFUN (area_shortcut,
"Enable shortcutting through the area\n"
"Disable shortcutting through the area\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int mode;
@@ -1327,7 +1331,7 @@ DEFUN (area_shortcut,
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
if (strncmp (argv[1], "de", 2) == 0)
mode = OSPF_SHORTCUT_DEFAULT;
@@ -1338,9 +1342,9 @@ DEFUN (area_shortcut,
else
return CMD_WARNING;
- ospf_area_shortcut_set (area, mode);
+ ospf_area_shortcut_set (ospf, area, mode);
- if (ospf_top->abr_type != OSPF_ABR_SHORTCUT)
+ if (ospf->abr_type != OSPF_ABR_SHORTCUT)
vty_out (vty, "Shortcut area setting will take effect "
"only when the router is configured as Shortcut ABR%s",
VTY_NEWLINE);
@@ -1359,17 +1363,18 @@ DEFUN (no_area_shortcut,
"Deconfigure enabled shortcutting through the area\n"
"Deconfigure disabled shortcutting through the area\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (!area)
return CMD_SUCCESS;
- ospf_area_shortcut_unset (area);
+ ospf_area_shortcut_unset (ospf, area);
return CMD_SUCCESS;
}
@@ -1617,6 +1622,7 @@ DEFUN (area_default_cost,
"Set the summary-default cost of a NSSA or stub area\n"
"Stub's advertised default summary cost\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
u_int32_t cost;
@@ -1625,7 +1631,7 @@ DEFUN (area_default_cost,
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
if (area->external_routing == OSPF_AREA_DEFAULT)
{
@@ -1648,6 +1654,7 @@ DEFUN (no_area_default_cost,
"Set the summary-default cost of a NSSA or stub area\n"
"Stub's advertised default summary cost\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
u_int32_t cost;
@@ -1656,7 +1663,7 @@ DEFUN (no_area_default_cost,
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return CMD_SUCCESS;
@@ -1668,7 +1675,7 @@ DEFUN (no_area_default_cost,
area->default_cost = 1;
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return CMD_SUCCESS;
}
@@ -1682,14 +1689,15 @@ DEFUN (area_export_list,
"Set the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]);
- area = ospf_area_get (area_id, format);
- ospf_area_export_list_set (area, argv[1]);
+ area = ospf_area_get (ospf, area_id, format);
+ ospf_area_export_list_set (ospf, area, argv[1]);
return CMD_SUCCESS;
}
@@ -1704,17 +1712,18 @@ DEFUN (no_area_export_list,
"Unset the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return CMD_SUCCESS;
- ospf_area_export_list_unset (area);
+ ospf_area_export_list_unset (ospf, area);
return CMD_SUCCESS;
}
@@ -1729,14 +1738,15 @@ DEFUN (area_import_list,
"Set the filter for networks from other areas announced to the specified one\n"
"Name of the access-list\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]);
- area = ospf_area_get (area_id, format);
- ospf_area_import_list_set (area, argv[1]);
+ area = ospf_area_get (ospf, area_id, format);
+ ospf_area_import_list_set (ospf, area, argv[1]);
return CMD_SUCCESS;
}
@@ -1751,16 +1761,17 @@ DEFUN (no_area_import_list,
"Unset the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return CMD_SUCCESS;
- ospf_area_import_list_unset (area);
+ ospf_area_import_list_unset (ospf, area);
return CMD_SUCCESS;
}
@@ -1777,6 +1788,7 @@ DEFUN (area_filter_list,
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
struct prefix_list *plist;
@@ -1784,7 +1796,7 @@ DEFUN (area_filter_list,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
plist = prefix_list_lookup (AFI_IP, argv[1]);
if (strncmp (argv[2], "in", 2) == 0)
{
@@ -1793,7 +1805,7 @@ DEFUN (area_filter_list,
free (PREFIX_NAME_IN (area));
PREFIX_NAME_IN (area) = strdup (argv[1]);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
else
{
@@ -1802,7 +1814,7 @@ DEFUN (area_filter_list,
free (PREFIX_NAME_OUT (area));
PREFIX_NAME_OUT (area) = strdup (argv[1]);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
return CMD_SUCCESS;
@@ -1821,6 +1833,7 @@ DEFUN (no_area_filter_list,
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
struct prefix_list *plist;
@@ -1828,7 +1841,7 @@ DEFUN (no_area_filter_list,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
plist = prefix_list_lookup (AFI_IP, argv[1]);
if (strncmp (argv[2], "in", 2) == 0)
{
@@ -1842,7 +1855,7 @@ DEFUN (no_area_filter_list,
PREFIX_NAME_IN (area) = NULL;
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
else
{
@@ -1856,7 +1869,7 @@ DEFUN (no_area_filter_list,
PREFIX_NAME_OUT (area) = NULL;
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
return CMD_SUCCESS;
@@ -1870,13 +1883,14 @@ DEFUN (area_authentication_message_digest,
"Enable authentication\n"
"Use message-digest authentication\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
return CMD_SUCCESS;
@@ -1890,13 +1904,14 @@ DEFUN (area_authentication,
"OSPF area ID as a decimal value\n"
"Enable authentication\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
area->auth_type = OSPF_AUTH_SIMPLE;
return CMD_SUCCESS;
@@ -1911,19 +1926,20 @@ DEFUN (no_area_authentication,
"OSPF area ID as a decimal value\n"
"Enable authentication\n")
{
+ struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return CMD_SUCCESS;
area->auth_type = OSPF_AUTH_NULL;
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return CMD_SUCCESS;
}
@@ -1939,6 +1955,7 @@ DEFUN (ospf_abr_type,
"Shortcut ABR\n"
"Standard behavior (RFC2328)\n")
{
+ struct ospf *ospf = vty->index;
u_char abr_type = OSPF_ABR_UNKNOWN;
if (strncmp (argv[0], "c", 1) == 0)
@@ -1953,10 +1970,10 @@ DEFUN (ospf_abr_type,
return CMD_WARNING;
/* If ABR type value is changed, schedule ABR task. */
- if (ospf_top->abr_type != abr_type)
+ if (ospf->abr_type != abr_type)
{
- ospf_top->abr_type = abr_type;
- ospf_schedule_abr_task ();
+ ospf->abr_type = abr_type;
+ ospf_schedule_abr_task (ospf);
}
return CMD_SUCCESS;
@@ -1972,6 +1989,7 @@ DEFUN (no_ospf_abr_type,
"Alternative ABR, IBM implementation\n"
"Shortcut ABR\n")
{
+ struct ospf *ospf = vty->index;
u_char abr_type = OSPF_ABR_UNKNOWN;
if (strncmp (argv[0], "c", 1) == 0)
@@ -1984,10 +2002,10 @@ DEFUN (no_ospf_abr_type,
return CMD_WARNING;
/* If ABR type value is changed, schedule ABR task. */
- if (ospf_top->abr_type == abr_type)
+ if (ospf->abr_type == abr_type)
{
- ospf_top->abr_type = OSPF_ABR_STAND;
- ospf_schedule_abr_task ();
+ ospf->abr_type = OSPF_ABR_STAND;
+ ospf_schedule_abr_task (ospf);
}
return CMD_SUCCESS;
@@ -2004,7 +2022,7 @@ DEFUN (ospf_compatible_rfc1583,
if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
- ospf_spf_calculate_schedule ();
+ ospf_spf_calculate_schedule (ospf);
}
return CMD_SUCCESS;
}
@@ -2021,7 +2039,7 @@ DEFUN (no_ospf_compatible_rfc1583,
if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
- ospf_spf_calculate_schedule ();
+ ospf_spf_calculate_schedule (ospf);
}
return CMD_SUCCESS;
}
@@ -2065,8 +2083,10 @@ DEFUN (no_timers_spf,
"Adjust routing timers\n"
"OSPF SPF timers\n")
{
- ospf_top->spf_delay = OSPF_SPF_DELAY_DEFAULT;
- ospf_top->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
+ struct ospf *ospf = vty->index;
+
+ ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
+ ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
return CMD_SUCCESS;
}
@@ -2259,6 +2279,7 @@ DEFUN (auto_cost_reference_bandwidth,
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
{
+ struct ospf *ospf = vty->index;
u_int32_t refbw;
listnode node;
@@ -2270,14 +2291,14 @@ DEFUN (auto_cost_reference_bandwidth,
}
/* If reference bandwidth is changed. */
- if ((refbw * 1000) == ospf_top->ref_bandwidth)
+ if ((refbw * 1000) == ospf->ref_bandwidth)
return CMD_SUCCESS;
- ospf_top->ref_bandwidth = refbw * 1000;
+ ospf->ref_bandwidth = refbw * 1000;
vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
- for (node = listhead (ospf_top->iflist); node; nextnode (node))
+ for (node = listhead (ospf->iflist); node; nextnode (node))
ospf_if_recalculate_output_cost (getdata (node));
return CMD_SUCCESS;
@@ -2290,61 +2311,22 @@ DEFUN (no_auto_cost_reference_bandwidth,
"Calculate OSPF interface cost according to bandwidth\n"
"Use reference bandwidth method to assign OSPF cost\n")
{
+ struct ospf *ospf = vty->index;
listnode node;
- if (ospf_top->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
+ if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
return CMD_SUCCESS;
- ospf_top->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
+ ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
-
- for (node = listhead (ospf_top->iflist); node; nextnode (node))
+ for (node = listhead (ospf->iflist); node; nextnode (node))
ospf_if_recalculate_output_cost (getdata (node));
return CMD_SUCCESS;
}
-
-DEFUN (clear_ip_ospf_neighbor,
- clear_ip_ospf_neighbor_cmd,
- "clear ip ospf neighbor A.B.C.D",
- "Reset functions\n"
- "IP\n"
- "Clear OSPF\n"
- "Neighbor list\n"
- "Neighbor ID\n")
-{
- listnode node;
- struct ospf_neighbor *nbr;
- struct in_addr router_id;
- int ret;
-
- ret = inet_aton (argv[0], &router_id);
- if (!ret)
- {
- vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id);
-
- if (nbr)
- {
- OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_SeqNumberMismatch);
- vty_out (vty, "clear neighbor %s%s", argv[0], VTY_NEWLINE);
- break;
- }
- }
-
- return CMD_SUCCESS;
-}
-
char *ospf_abr_type_descr_str[] =
{
"Unknown",
@@ -2453,9 +2435,10 @@ DEFUN (show_ip_ospf,
{
listnode node;
struct ospf_area * area;
+ struct ospf *ospf = ospf_top;
/* Check OSPF is enable. */
- if (ospf_top == NULL)
+ if (ospf == NULL)
{
vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
return CMD_SUCCESS;
@@ -2463,51 +2446,51 @@ DEFUN (show_ip_ospf,
/* Show Router ID. */
vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
- inet_ntoa (ospf_top->router_id),
+ inet_ntoa (ospf->router_id),
VTY_NEWLINE);
/* Show capability. */
vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
vty_out (vty, " RFC1583Compatibility flag is %s%s",
- CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE) ?
+ CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
"enabled" : "disabled", VTY_NEWLINE);
#ifdef HAVE_OPAQUE_LSA
vty_out (vty, " OpaqueCapability flag is %s%s%s",
- CHECK_FLAG (ospf_top->config, OSPF_OPAQUE_CAPABLE) ?
+ CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
"enabled" : "disabled",
- IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf_top->opaque) ?
+ IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
" (origination blocked)" : "",
VTY_NEWLINE);
#endif /* HAVE_OPAQUE_LSA */
/* Show SPF timers. */
vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
- ospf_top->spf_delay, ospf_top->spf_holdtime, VTY_NEWLINE);
+ ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
/* Show refresh parameters. */
vty_out (vty, " Refresh timer %d secs%s",
- ospf_top->lsa_refresh_interval, VTY_NEWLINE);
+ ospf->lsa_refresh_interval, VTY_NEWLINE);
/* Show ABR/ASBR flags. */
- if (CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ABR))
+ if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
vty_out (vty, " This router is an ABR, ABR type is: %s%s",
- ospf_abr_type_descr_str[ospf_top->abr_type], VTY_NEWLINE);
+ ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
- if (CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ASBR))
+ if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
vty_out (vty, " This router is an ASBR "
"(injecting external routing information)%s", VTY_NEWLINE);
/* Show Number of AS-external-LSAs. */
vty_out (vty, " Number of external LSA %ld%s",
- ospf_lsdb_count_all (ospf_top->lsdb), VTY_NEWLINE);
+ ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
/* Show number of areas attached. */
vty_out (vty, " Number of areas attached to this router: %d%s%s",
- listcount (ospf_top->areas), VTY_NEWLINE, VTY_NEWLINE);
+ listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
/* Show each area status. */
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
show_ip_ospf_area (vty, area);
@@ -2516,7 +2499,8 @@ DEFUN (show_ip_ospf,
void
-show_ip_ospf_interface_sub (struct vty *vty, struct interface *ifp)
+show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
+ struct interface *ifp)
{
struct ospf_neighbor *nbr;
int oi_count;
@@ -2564,7 +2548,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct interface *ifp)
VTY_NEWLINE);
vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
- inet_ntoa (ospf_top->router_id), ospf_network_type_str[oi->type],
+ inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
oi->output_cost, VTY_NEWLINE);
vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
@@ -2620,7 +2604,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct interface *ifp)
vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
- ospf_nbr_count (oi->nbrs, 0), ospf_nbr_count (oi->nbrs, NSM_Full),
+ ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
VTY_NEWLINE);
}
}
@@ -2635,19 +2619,20 @@ DEFUN (show_ip_ospf_interface,
"Interface name\n")
{
struct interface *ifp;
+ struct ospf *ospf = ospf_top;
listnode node;
/* Show All Interfaces. */
if (argc == 0)
for (node = listhead (iflist); node; nextnode (node))
- show_ip_ospf_interface_sub (vty, node->data);
+ show_ip_ospf_interface_sub (vty, ospf, node->data);
/* Interface name is specified. */
else
{
if ((ifp = if_lookup_by_name (argv[0])) == NULL)
vty_out (vty, "No such interface name%s", VTY_NEWLINE);
else
- show_ip_ospf_interface_sub (vty, ifp);
+ show_ip_ospf_interface_sub (vty, ospf, ifp);
}
return CMD_SUCCESS;
@@ -2694,9 +2679,10 @@ DEFUN (show_ip_ospf_neighbor,
"OSPF information\n"
"Neighbor list\n")
{
+ struct ospf *ospf = ospf_top;
listnode node;
- if (!ospf_top)
+ if (ospf == NULL)
{
vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
return CMD_SUCCESS;
@@ -2707,7 +2693,7 @@ DEFUN (show_ip_ospf_neighbor,
"Time Address Interface RXmtL "
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
show_ip_ospf_neighbor_sub (vty, getdata (node));
return CMD_SUCCESS;
@@ -2722,9 +2708,10 @@ DEFUN (show_ip_ospf_neighbor_all,
"Neighbor list\n"
"include down status neighbor\n")
{
+ struct ospf *ospf = vty->index;
listnode node;
- if (!ospf_top)
+ if (ospf == NULL)
{
vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
return CMD_SUCCESS;
@@ -2735,7 +2722,7 @@ DEFUN (show_ip_ospf_neighbor_all,
"Time Address Interface RXmtL "
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
listnode nbr_node;
@@ -2773,11 +2760,12 @@ DEFUN (show_ip_ospf_neighbor_int,
"Neighbor list\n"
"Interface name\n")
{
+ struct ospf *ospf = ospf_top;
struct ospf_interface *oi;
struct in_addr addr;
int ret;
- if (!ospf_top)
+ if (ospf == NULL)
{
vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
return CMD_SUCCESS;
@@ -2791,7 +2779,7 @@ DEFUN (show_ip_ospf_neighbor_int,
return CMD_WARNING;
}
- if ((oi = ospf_if_is_configured (&addr)) == NULL)
+ if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
vty_out (vty, "No such interface address%s", VTY_NEWLINE);
else
{
@@ -2903,6 +2891,7 @@ DEFUN (show_ip_ospf_neighbor_id,
"Neighbor list\n"
"Neighbor ID\n")
{
+ struct ospf *ospf = ospf_top;
listnode node;
struct ospf_neighbor *nbr;
struct in_addr router_id;
@@ -2915,7 +2904,7 @@ DEFUN (show_ip_ospf_neighbor_id,
return CMD_WARNING;
}
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
@@ -2939,12 +2928,13 @@ DEFUN (show_ip_ospf_neighbor_detail,
"Neighbor list\n"
"detail of all neighbors\n")
{
+ struct ospf *ospf = ospf_top;
listnode node;
- if (!ospf_top)
+ if (ospf == NULL)
return CMD_SUCCESS;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
struct route_node *rn;
@@ -2970,12 +2960,13 @@ DEFUN (show_ip_ospf_neighbor_detail_all,
"detail of all neighbors\n"
"include down status neighbor\n")
{
+ struct ospf *ospf = ospf_top;
listnode node;
- if (!ospf_top)
+ if (ospf == NULL)
return CMD_SUCCESS;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
struct route_node *rn;
@@ -3026,7 +3017,10 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
return CMD_WARNING;
}
- if ((oi = ospf_if_is_configured (&addr)) == NULL)
+ if (ospf_top == NULL)
+ return CMD_WARNING;
+
+ if ((oi = ospf_if_is_configured (ospf_top, &addr)) == NULL)
vty_out (vty, "No such interface address%s", VTY_NEWLINE);
else
{
@@ -3204,7 +3198,7 @@ char *link_id_desc[] =
"(null)",
"Neighboring Router ID",
"Designated Router address",
- "Network/subnet number",
+ "Net",
"Neighboring Router ID",
};
@@ -3510,6 +3504,7 @@ void
show_lsa_detail (struct vty *vty, int type,
struct in_addr *id, struct in_addr *adv_router)
{
+ struct ospf *ospf = ospf_top;
listnode node;
switch (type)
@@ -3521,10 +3516,10 @@ show_lsa_detail (struct vty *vty, int type,
vty_out (vty, " %s %s%s",
show_database_desc[type],
VTY_NEWLINE, VTY_NEWLINE);
- show_lsa_detail_proc (vty, AS_LSDB (ospf_top, type), id, adv_router);
+ show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
break;
default:
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = node->data;
vty_out (vty, "%s %s (Area %s)%s%s",
@@ -3561,6 +3556,7 @@ void
show_lsa_detail_adv_router (struct vty *vty, int type,
struct in_addr *adv_router)
{
+ struct ospf *ospf = ospf_top;
listnode node;
switch (type)
@@ -3572,11 +3568,11 @@ show_lsa_detail_adv_router (struct vty *vty, int type,
vty_out (vty, " %s %s%s",
show_database_desc[type],
VTY_NEWLINE, VTY_NEWLINE);
- show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf_top, type),
+ show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
adv_router);
break;
default:
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = node->data;
vty_out (vty, "%s %s (Area %s)%s%s",
@@ -3592,10 +3588,11 @@ show_lsa_detail_adv_router (struct vty *vty, int type,
void
show_ip_ospf_database_summary (struct vty *vty, int self)
{
+ struct ospf *ospf = ospf_top;
listnode node;
int type;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = node->data;
for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
@@ -3638,15 +3635,15 @@ show_ip_ospf_database_summary (struct vty *vty, int self)
default:
continue;
}
- if (ospf_lsdb_count_self (ospf_top->lsdb, type) ||
- (!self && ospf_lsdb_count (ospf_top->lsdb, type)))
+ if (ospf_lsdb_count_self (ospf->lsdb, type) ||
+ (!self && ospf_lsdb_count (ospf->lsdb, type)))
{
vty_out (vty, " %s%s%s",
show_database_desc[type],
VTY_NEWLINE, VTY_NEWLINE);
vty_out (vty, "%s%s", show_database_header[type],
VTY_NEWLINE);
- foreach_lsa (AS_LSDB (ospf_top, type), vty, self, show_lsa_summary);
+ foreach_lsa (AS_LSDB (ospf, type), vty, self, show_lsa_summary);
vty_out (vty, "%s", VTY_NEWLINE);
}
}
@@ -3657,13 +3654,14 @@ show_ip_ospf_database_summary (struct vty *vty, int self)
void
show_ip_ospf_database_maxage (struct vty *vty)
{
+ struct ospf *ospf = ospf_top;
listnode node;
struct ospf_lsa *lsa;
vty_out (vty, "%s MaxAge Link States:%s%s",
VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf_top->maxage_lsa); node; nextnode (node))
+ for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
if ((lsa = node->data) != NULL)
{
vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
@@ -3720,14 +3718,15 @@ DEFUN (show_ip_ospf_database,
"OSPF information\n"
"Database summary\n")
{
+ struct ospf *ospf = ospf_top;
int type, ret;
struct in_addr id, adv_router;
- if (ospf_top == NULL)
+ if (ospf == NULL)
return CMD_SUCCESS;
vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
- inet_ntoa (ospf_top->router_id), VTY_NEWLINE, VTY_NEWLINE);
+ inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
/* Show all LSA. */
if (argc == 0)
@@ -3788,7 +3787,7 @@ DEFUN (show_ip_ospf_database,
else if (argc == 3)
{
if (strncmp (argv[2], "s", 1) == 0)
- adv_router = ospf_top->router_id;
+ adv_router = ospf->router_id;
else
{
ret = inet_aton (argv[2], &adv_router);
@@ -3858,14 +3857,15 @@ DEFUN (show_ip_ospf_database_type_adv_router,
"Advertising Router link states\n"
"Advertising Router (as an IP address)\n")
{
+ struct ospf *ospf = ospf_top;
int type, ret;
struct in_addr adv_router;
- if (ospf_top == NULL)
+ if (ospf == NULL)
return CMD_SUCCESS;
vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
- inet_ntoa (ospf_top->router_id), VTY_NEWLINE, VTY_NEWLINE);
+ inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
if (argc != 2)
return CMD_WARNING;
@@ -3898,7 +3898,7 @@ DEFUN (show_ip_ospf_database_type_adv_router,
/* `show ip ospf database LSA adv-router ADV_ROUTER'. */
if (strncmp (argv[1], "s", 1) == 0)
- adv_router = ospf_top->router_id;
+ adv_router = ospf->router_id;
else
{
ret = inet_aton (argv[1], &adv_router);
@@ -4489,6 +4489,7 @@ DEFUN (ip_ospf_dead_interval,
struct ospf_if_params *params;
struct ospf_interface *oi;
struct route_node *rn;
+ struct ospf *ospf = ospf_top;
params = IF_DEF_PARAMS (ifp);
@@ -4521,9 +4522,12 @@ DEFUN (ip_ospf_dead_interval,
/* Update timer values in neighbor structure. */
if (argc == 2)
{
- oi = ospf_if_lookup_by_local_addr (ifp, addr);
- if (oi)
- ospf_nbr_timer_update (oi);
+ if (ospf)
+ {
+ oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
+ if (oi)
+ ospf_nbr_timer_update (oi);
+ }
}
else
{
@@ -4565,6 +4569,7 @@ DEFUN (no_ip_ospf_dead_interval,
struct ospf_if_params *params;
struct ospf_interface *oi;
struct route_node *rn;
+ struct ospf *ospf = ospf_top;
ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
@@ -4596,9 +4601,12 @@ DEFUN (no_ip_ospf_dead_interval,
/* Update timer values in neighbor structure. */
if (argc == 1)
{
- oi = ospf_if_lookup_by_local_addr (ifp, addr);
- if (oi)
- ospf_nbr_timer_update (oi);
+ if (ospf)
+ {
+ oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
+ if (oi)
+ ospf_nbr_timer_update (oi);
+ }
}
else
{
@@ -5516,13 +5524,14 @@ DEFUN (ospf_distribute_list_out,
"Routing Information Protocol (RIP)\n"
"Border Gateway Protocol (BGP)\n")
{
+ struct ospf *ospf = vty->index;
int source;
/* Get distribute source. */
if (!str2distribute_source (argv[1], &source))
return CMD_WARNING;
- return ospf_distribute_list_out_set (source, argv[0]);
+ return ospf_distribute_list_out_set (ospf, source, argv[0]);
}
DEFUN (no_ospf_distribute_list_out,
@@ -5538,12 +5547,13 @@ DEFUN (no_ospf_distribute_list_out,
"Routing Information Protocol (RIP)\n"
"Border Gateway Protocol (BGP)\n")
{
+ struct ospf *ospf = vty->index;
int source;
if (!str2distribute_source (argv[1], &source))
return CMD_WARNING;
- return ospf_distribute_list_out_unset (source, argv[0]);
+ return ospf_distribute_list_out_unset (ospf, source, argv[0]);
}
/* Default information originate. */
@@ -5930,6 +5940,7 @@ DEFUN (no_ospf_default_information_originate,
"Control distribution of default information\n"
"Distribute a default route\n")
{
+ struct ospf *ospf = vty->index;
struct prefix_ipv4 p;
struct in_addr nexthop;
@@ -5937,7 +5948,7 @@ DEFUN (no_ospf_default_information_originate,
p.prefix.s_addr = 0;
p.prefixlen = 0;
- ospf_external_lsa_flush (DEFAULT_ROUTE, &p, 0, nexthop);
+ ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
ospf_external_info_delete (DEFAULT_ROUTE, p);
@@ -5955,12 +5966,13 @@ DEFUN (ospf_default_metric,
"Set metric of redistributed routes\n"
"Default metric\n")
{
+ struct ospf *ospf = vty->index;
int metric = -1;
if (!str2metric (argv[0], &metric))
return CMD_WARNING;
- ospf_top->default_metric = metric;
+ ospf->default_metric = metric;
return CMD_SUCCESS;
}
@@ -5971,7 +5983,10 @@ DEFUN (no_ospf_default_metric,
NO_STR
"Set metric of redistributed routes\n")
{
- ospf_top->default_metric = -1;
+ struct ospf *ospf = vty->index;
+
+ ospf->default_metric = -1;
+
return CMD_SUCCESS;
}
@@ -5988,7 +6003,10 @@ DEFUN (ospf_distance,
"Define an administrative distance\n"
"OSPF Administrative distance\n")
{
- ospf_top->distance_all = atoi (argv[0]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_all = atoi (argv[0]);
+
return CMD_SUCCESS;
}
@@ -5999,7 +6017,10 @@ DEFUN (no_ospf_distance,
"Define an administrative distance\n"
"OSPF Administrative distance\n")
{
- ospf_top->distance_all = 0;
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_all = 0;
+
return CMD_SUCCESS;
}
@@ -6011,9 +6032,12 @@ DEFUN (no_ospf_distance_ospf,
"OSPF Administrative distance\n"
"OSPF Distance\n")
{
- ospf_top->distance_intra = 0;
- ospf_top->distance_inter = 0;
- ospf_top->distance_external = 0;
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_intra = 0;
+ ospf->distance_inter = 0;
+ ospf->distance_external = 0;
+
return CMD_SUCCESS;
}
@@ -6025,7 +6049,10 @@ DEFUN (ospf_distance_ospf_intra,
"Intra-area routes\n"
"Distance for intra-area routes\n")
{
- ospf_top->distance_intra = atoi (argv[0]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_intra = atoi (argv[0]);
+
return CMD_SUCCESS;
}
@@ -6039,8 +6066,11 @@ DEFUN (ospf_distance_ospf_intra_inter,
"Inter-area routes\n"
"Distance for inter-area routes\n")
{
- ospf_top->distance_intra = atoi (argv[0]);
- ospf_top->distance_inter = atoi (argv[1]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_intra = atoi (argv[0]);
+ ospf->distance_inter = atoi (argv[1]);
+
return CMD_SUCCESS;
}
@@ -6054,8 +6084,11 @@ DEFUN (ospf_distance_ospf_intra_external,
"External routes\n"
"Distance for external routes\n")
{
- ospf_top->distance_intra = atoi (argv[0]);
- ospf_top->distance_external = atoi (argv[1]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_intra = atoi (argv[0]);
+ ospf->distance_external = atoi (argv[1]);
+
return CMD_SUCCESS;
}
@@ -6071,9 +6104,12 @@ DEFUN (ospf_distance_ospf_intra_inter_external,
"External routes\n"
"Distance for external routes\n")
{
- ospf_top->distance_intra = atoi (argv[0]);
- ospf_top->distance_inter = atoi (argv[1]);
- ospf_top->distance_external = atoi (argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_intra = atoi (argv[0]);
+ ospf->distance_inter = atoi (argv[1]);
+ ospf->distance_external = atoi (argv[2]);
+
return CMD_SUCCESS;
}
@@ -6089,9 +6125,12 @@ DEFUN (ospf_distance_ospf_intra_external_inter,
"Inter-area routes\n"
"Distance for inter-area routes\n")
{
- ospf_top->distance_intra = atoi (argv[0]);
- ospf_top->distance_external = atoi (argv[1]);
- ospf_top->distance_inter = atoi (argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_intra = atoi (argv[0]);
+ ospf->distance_external = atoi (argv[1]);
+ ospf->distance_inter = atoi (argv[2]);
+
return CMD_SUCCESS;
}
@@ -6103,7 +6142,10 @@ DEFUN (ospf_distance_ospf_inter,
"Inter-area routes\n"
"Distance for inter-area routes\n")
{
- ospf_top->distance_inter = atoi (argv[0]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_inter = atoi (argv[0]);
+
return CMD_SUCCESS;
}
@@ -6117,8 +6159,11 @@ DEFUN (ospf_distance_ospf_inter_intra,
"Intra-area routes\n"
"Distance for intra-area routes\n")
{
- ospf_top->distance_inter = atoi (argv[0]);
- ospf_top->distance_intra = atoi (argv[1]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_inter = atoi (argv[0]);
+ ospf->distance_intra = atoi (argv[1]);
+
return CMD_SUCCESS;
}
@@ -6132,8 +6177,11 @@ DEFUN (ospf_distance_ospf_inter_external,
"External routes\n"
"Distance for external routes\n")
{
- ospf_top->distance_inter = atoi (argv[0]);
- ospf_top->distance_external = atoi (argv[1]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_inter = atoi (argv[0]);
+ ospf->distance_external = atoi (argv[1]);
+
return CMD_SUCCESS;
}
@@ -6149,9 +6197,12 @@ DEFUN (ospf_distance_ospf_inter_intra_external,
"External routes\n"
"Distance for external routes\n")
{
- ospf_top->distance_inter = atoi (argv[0]);
- ospf_top->distance_intra = atoi (argv[1]);
- ospf_top->distance_external = atoi (argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_inter = atoi (argv[0]);
+ ospf->distance_intra = atoi (argv[1]);
+ ospf->distance_external = atoi (argv[2]);
+
return CMD_SUCCESS;
}
@@ -6167,9 +6218,12 @@ DEFUN (ospf_distance_ospf_inter_external_intra,
"Intra-area routes\n"
"Distance for intra-area routes\n")
{
- ospf_top->distance_inter = atoi (argv[0]);
- ospf_top->distance_external = atoi (argv[1]);
- ospf_top->distance_intra = atoi (argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_inter = atoi (argv[0]);
+ ospf->distance_external = atoi (argv[1]);
+ ospf->distance_intra = atoi (argv[2]);
+
return CMD_SUCCESS;
}
@@ -6181,7 +6235,10 @@ DEFUN (ospf_distance_ospf_external,
"External routes\n"
"Distance for external routes\n")
{
- ospf_top->distance_external = atoi (argv[0]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_external = atoi (argv[0]);
+
return CMD_SUCCESS;
}
@@ -6195,8 +6252,11 @@ DEFUN (ospf_distance_ospf_external_intra,
"Intra-area routes\n"
"Distance for intra-area routes\n")
{
- ospf_top->distance_external = atoi (argv[0]);
- ospf_top->distance_intra = atoi (argv[1]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_external = atoi (argv[0]);
+ ospf->distance_intra = atoi (argv[1]);
+
return CMD_SUCCESS;
}
@@ -6210,8 +6270,11 @@ DEFUN (ospf_distance_ospf_external_inter,
"Inter-area routes\n"
"Distance for inter-area routes\n")
{
- ospf_top->distance_external = atoi (argv[0]);
- ospf_top->distance_inter = atoi (argv[1]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_external = atoi (argv[0]);
+ ospf->distance_inter = atoi (argv[1]);
+
return CMD_SUCCESS;
}
@@ -6227,9 +6290,12 @@ DEFUN (ospf_distance_ospf_external_intra_inter,
"Inter-area routes\n"
"Distance for inter-area routes\n")
{
- ospf_top->distance_external = atoi (argv[0]);
- ospf_top->distance_intra = atoi (argv[1]);
- ospf_top->distance_inter = atoi (argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_external = atoi (argv[0]);
+ ospf->distance_intra = atoi (argv[1]);
+ ospf->distance_inter = atoi (argv[2]);
+
return CMD_SUCCESS;
}
@@ -6245,9 +6311,12 @@ DEFUN (ospf_distance_ospf_external_inter_intra,
"Intra-area routes\n"
"Distance for intra-area routes\n")
{
- ospf_top->distance_external = atoi (argv[0]);
- ospf_top->distance_inter = atoi (argv[1]);
- ospf_top->distance_intra = atoi (argv[2]);
+ struct ospf *ospf = vty->index;
+
+ ospf->distance_external = atoi (argv[0]);
+ ospf->distance_inter = atoi (argv[1]);
+ ospf->distance_intra = atoi (argv[2]);
+
return CMD_SUCCESS;
}
@@ -6259,6 +6328,7 @@ DEFUN (ospf_distance_source,
"IP source prefix\n")
{
ospf_distance_set (vty, argv[0], argv[1], NULL);
+
return CMD_SUCCESS;
}
@@ -6458,13 +6528,15 @@ DEFUN (show_ip_ospf_border_routers,
"show all the ABR's and ASBR's\n"
"for this area\n")
{
- if (ospf_top == NULL)
+ struct ospf *ospf = ospf_top;
+
+ if (ospf == NULL)
{
vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
- if (ospf_top->new_table == NULL)
+ if (ospf->new_table == NULL)
{
vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
return CMD_SUCCESS;
@@ -6474,7 +6546,7 @@ DEFUN (show_ip_ospf_border_routers,
show_ip_ospf_route_network (vty, ospf_top->new_table); */
/* Show Router routes. */
- show_ip_ospf_route_router (vty, ospf_top->new_rtrs);
+ show_ip_ospf_route_router (vty, ospf->new_rtrs);
return CMD_SUCCESS;
}
@@ -6488,26 +6560,28 @@ DEFUN (show_ip_ospf_route,
"OSPF information\n"
"OSPF routing table\n")
{
- if (ospf_top == NULL)
+ struct ospf *ospf = ospf_top;
+
+ if (ospf == NULL)
{
vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
- if (ospf_top->new_table == NULL)
+ if (ospf->new_table == NULL)
{
vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
/* Show Network routes. */
- show_ip_ospf_route_network (vty, ospf_top->new_table);
+ show_ip_ospf_route_network (vty, ospf->new_table);
/* Show Router routes. */
- show_ip_ospf_route_router (vty, ospf_top->new_rtrs);
+ show_ip_ospf_route_router (vty, ospf->new_rtrs);
/* Show AS External routes. */
- show_ip_ospf_route_external (vty, ospf_top->old_external_route);
+ show_ip_ospf_route_external (vty, ospf->old_external_route);
return CMD_SUCCESS;
}
@@ -6736,13 +6810,13 @@ config_write_interface (struct vty *vty)
}
int
-config_write_network_area (struct vty *vty)
+config_write_network_area (struct vty *vty, struct ospf *ospf)
{
struct route_node *rn;
u_char buf[INET_ADDRSTRLEN];
/* `network area' print. */
- for (rn = route_top (ospf_top->networks); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
if (rn->info)
{
struct ospf_network *n = rn->info;
@@ -6766,13 +6840,13 @@ config_write_network_area (struct vty *vty)
}
int
-config_write_ospf_area (struct vty *vty)
+config_write_ospf_area (struct vty *vty, struct ospf *ospf)
{
listnode node;
u_char buf[INET_ADDRSTRLEN];
/* Area configuration print. */
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
struct ospf_area *area = getdata (node);
struct route_node *rn1;
@@ -6858,13 +6932,13 @@ config_write_ospf_area (struct vty *vty)
}
int
-config_write_ospf_nbr_nbma (struct vty *vty)
+config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
{
struct ospf_nbr_nbma *nbr_nbma;
struct route_node *rn;
/* Static Neighbor configuration print. */
- for (rn = route_top (ospf_top->nbr_nbma); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
if ((nbr_nbma = rn->info))
{
vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
@@ -6882,13 +6956,13 @@ config_write_ospf_nbr_nbma (struct vty *vty)
}
int
-config_write_virtual_link (struct vty *vty)
+config_write_virtual_link (struct vty *vty, struct ospf *ospf)
{
listnode node;
u_char buf[INET_ADDRSTRLEN];
/* Virtual-Link print */
- for (node = listhead (ospf_top->vlinks); node; nextnode (node))
+ for (node = listhead (ospf->vlinks); node; nextnode (node))
{
listnode n2;
struct crypt_key *ck;
@@ -6949,7 +7023,7 @@ config_write_virtual_link (struct vty *vty)
char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
"ripng", "ospf", "ospf6", "bgp"};
int
-config_write_ospf_redistribute (struct vty *vty)
+config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
{
int type;
@@ -6958,10 +7032,10 @@ config_write_ospf_redistribute (struct vty *vty)
if (type != zclient->redist_default && zclient->redist[type])
{
vty_out (vty, " redistribute %s", distribute_str[type]);
- if (ospf_top->dmetric[type].value >= 0)
+ if (ospf->dmetric[type].value >= 0)
vty_out (vty, " metric %d", ospf_top->dmetric[type].value);
- if (ospf_top->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
+ if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
vty_out (vty, " metric-type 1");
if (ROUTEMAP_NAME (type))
@@ -6974,40 +7048,40 @@ config_write_ospf_redistribute (struct vty *vty)
}
int
-config_write_ospf_default_metric (struct vty *vty)
+config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
{
- if (ospf_top->default_metric != -1)
- vty_out (vty, " default-metric %d%s", ospf_top->default_metric,
+ if (ospf->default_metric != -1)
+ vty_out (vty, " default-metric %d%s", ospf->default_metric,
VTY_NEWLINE);
return 0;
}
int
-config_write_ospf_distribute (struct vty *vty)
+config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
{
int type;
- if (ospf_top)
+ if (ospf)
{
/* distribute-list print. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
- if (ospf_top->dlist[type].name)
+ if (ospf->dlist[type].name)
vty_out (vty, " distribute-list %s out %s%s",
- ospf_top->dlist[type].name,
+ ospf->dlist[type].name,
distribute_str[type], VTY_NEWLINE);
/* default-information print. */
- if (ospf_top->default_originate != DEFAULT_ORIGINATE_NONE)
+ if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
{
- if (ospf_top->default_originate == DEFAULT_ORIGINATE_ZEBRA)
+ if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
vty_out (vty, " default-information originate");
else
vty_out (vty, " default-information originate always");
- if (ospf_top->dmetric[DEFAULT_ROUTE].value >= 0)
+ if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
vty_out (vty, " metric %d",
- ospf_top->dmetric[DEFAULT_ROUTE].value);
- if (ospf_top->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
+ ospf->dmetric[DEFAULT_ROUTE].value);
+ if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
vty_out (vty, " metric-type 1");
if (ROUTEMAP_NAME (DEFAULT_ROUTE))
@@ -7022,31 +7096,31 @@ config_write_ospf_distribute (struct vty *vty)
}
int
-config_write_ospf_distance (struct vty *vty)
+config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
{
struct route_node *rn;
struct ospf_distance *odistance;
- if (ospf_top->distance_all)
- vty_out (vty, " distance %d%s", ospf_top->distance_all, VTY_NEWLINE);
+ if (ospf->distance_all)
+ vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
- if (ospf_top->distance_intra
- || ospf_top->distance_inter
- || ospf_top->distance_external)
+ if (ospf->distance_intra
+ || ospf->distance_inter
+ || ospf->distance_external)
{
vty_out (vty, " distance ospf");
- if (ospf_top->distance_intra)
- vty_out (vty, " intra-area %d", ospf_top->distance_intra);
- if (ospf_top->distance_inter)
- vty_out (vty, " inter-area %d", ospf_top->distance_inter);
- if (ospf_top->distance_external)
- vty_out (vty, " external %d", ospf_top->distance_external);
+ if (ospf->distance_intra)
+ vty_out (vty, " intra-area %d", ospf->distance_intra);
+ if (ospf->distance_inter)
+ vty_out (vty, " inter-area %d", ospf->distance_inter);
+ if (ospf->distance_external)
+ vty_out (vty, " external %d", ospf->distance_external);
vty_out (vty, "%s", VTY_NEWLINE);
}
- for (rn = route_top (ospf_top->distance_table); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
if ((odistance = rn->info) != NULL)
{
vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
@@ -7061,54 +7135,55 @@ config_write_ospf_distance (struct vty *vty)
int
ospf_config_write (struct vty *vty)
{
+ struct ospf *ospf = ospf_top;
listnode node;
int write = 0;
- if (ospf_top != NULL)
+ if (ospf != NULL)
{
/* `router ospf' print. */
vty_out (vty, "router ospf%s", VTY_NEWLINE);
write++;
- if (!ospf_top->networks)
+ if (!ospf->networks)
return write;
/* Router ID print. */
- if (ospf_top->router_id_static.s_addr != 0)
+ if (ospf->router_id_static.s_addr != 0)
vty_out (vty, " ospf router-id %s%s",
- inet_ntoa (ospf_top->router_id_static), VTY_NEWLINE);
+ inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
/* ABR type print. */
- if (ospf_top->abr_type != OSPF_ABR_STAND)
+ if (ospf->abr_type != OSPF_ABR_STAND)
vty_out (vty, " ospf abr-type %s%s",
- ospf_abr_type_str[ospf_top->abr_type], VTY_NEWLINE);
+ ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
/* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
- if (CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE))
+ if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
/* auto-cost reference-bandwidth configuration. */
- if (ospf_top->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
+ if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
vty_out (vty, " auto-cost reference-bandwidth %d%s",
- ospf_top->ref_bandwidth / 1000, VTY_NEWLINE);
+ ospf->ref_bandwidth / 1000, VTY_NEWLINE);
/* SPF timers print. */
- if (ospf_top->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
- ospf_top->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
+ if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
+ ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
vty_out (vty, " timers spf %d %d%s",
- ospf_top->spf_delay, ospf_top->spf_holdtime, VTY_NEWLINE);
+ ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
/* SPF refresh parameters print. */
- if (ospf_top->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
+ if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
vty_out (vty, " refresh timer %d%s",
- ospf_top->lsa_refresh_interval, VTY_NEWLINE);
+ ospf->lsa_refresh_interval, VTY_NEWLINE);
/* Redistribute information print. */
- config_write_ospf_redistribute (vty);
+ config_write_ospf_redistribute (vty, ospf);
/* passive-interface print. */
- for (node = listhead (ospf_top->iflist); node; nextnode (node))
+ for (node = listhead (ospf->iflist); node; nextnode (node))
{
struct interface *ifp = getdata (node);
@@ -7119,7 +7194,7 @@ ospf_config_write (struct vty *vty)
ifp->name, VTY_NEWLINE);
}
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
@@ -7131,28 +7206,28 @@ ospf_config_write (struct vty *vty)
/* Network area print. */
- config_write_network_area (vty);
+ config_write_network_area (vty, ospf);
/* Area config print. */
- config_write_ospf_area (vty);
+ config_write_ospf_area (vty, ospf);
/* static neighbor print. */
- config_write_ospf_nbr_nbma (vty);
+ config_write_ospf_nbr_nbma (vty, ospf);
/* Virtual-Link print. */
- config_write_virtual_link (vty);
+ config_write_virtual_link (vty, ospf);
/* Default metric configuration. */
- config_write_ospf_default_metric (vty);
+ config_write_ospf_default_metric (vty, ospf);
/* Distribute-list and default-information print. */
- config_write_ospf_distribute (vty);
+ config_write_ospf_distribute (vty, ospf);
/* Distance configuration. */
- config_write_ospf_distance (vty);
+ config_write_ospf_distance (vty, ospf);
#ifdef HAVE_OPAQUE_LSA
- ospf_opaque_config_write_router (vty, ospf_top);
+ ospf_opaque_config_write_router (vty, ospf);
#endif /* HAVE_OPAQUE_LSA */
}
@@ -7569,3 +7644,4 @@ ospf_vty_init ()
ospf_vty_zebra_init ();
}
+
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 1ad31f29..1f11369b 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -59,6 +59,7 @@ int
ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length)
{
struct interface *ifp;
+ struct ospf *ospf = ospf_top;
ifp = zebra_interface_add_read (zclient->ibuf);
@@ -79,7 +80,7 @@ ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length)
IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_LOOPBACK;
}
- ospf_if_update ();
+ ospf_if_update (ospf);
#ifdef HAVE_SNMP
ospf_snmp_if_update (ifp);
@@ -242,6 +243,7 @@ int
ospf_interface_address_add (int command, struct zclient *zclient,
zebra_size_t length)
{
+ struct ospf *ospf = ospf_top;
struct connected *c;
c = zebra_interface_address_add_read (zclient->ibuf);
@@ -249,19 +251,7 @@ ospf_interface_address_add (int command, struct zclient *zclient,
if (c == NULL)
return 0;
-#if 0
- if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
- {
- struct prefix *p;
-
- p = c->address;
- if (p->family == AF_INET)
- zlog_info (" connected address %s/%d",
- inet_atop (p->u.prefix4), p->prefixlen);
- }
-#endif
-
- ospf_if_update ();
+ ospf_if_update (ospf);
#ifdef HAVE_SNMP
ospf_snmp_if_update (c->ifp);
@@ -274,6 +264,7 @@ int
ospf_interface_address_delete (int command, struct zclient *zclient,
zebra_size_t length)
{
+ struct ospf *ospf = ospf_top;
struct connected *c;
struct interface *ifp;
struct ospf_interface *oi;
@@ -305,7 +296,7 @@ ospf_interface_address_delete (int command, struct zclient *zclient,
connected_free (c);
- ospf_if_update();
+ ospf_if_update (ospf);
return 0;
}
@@ -479,42 +470,43 @@ ospf_is_type_redistributed (int type)
int
ospf_redistribute_set (int type, int mtype, int mvalue)
{
+ struct ospf *ospf = ospf_top;
int force = 0;
if (ospf_is_type_redistributed (type))
{
- if (mtype != ospf_top->dmetric[type].type)
+ if (mtype != ospf->dmetric[type].type)
{
- ospf_top->dmetric[type].type = mtype;
+ ospf->dmetric[type].type = mtype;
force = LSA_REFRESH_FORCE;
}
- if (mvalue != ospf_top->dmetric[type].value)
+ if (mvalue != ospf->dmetric[type].value)
{
- ospf_top->dmetric[type].value = mvalue;
+ ospf->dmetric[type].value = mvalue;
force = LSA_REFRESH_FORCE;
}
- ospf_external_lsa_refresh_type (type, force);
+ ospf_external_lsa_refresh_type (ospf, type, force);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_info ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
LOOKUP (ospf_redistributed_proto, type),
- metric_type (type), metric_value (type));
+ metric_type (ospf, type), metric_value (ospf, type));
return CMD_SUCCESS;
}
- ospf_top->dmetric[type].type = mtype;
- ospf_top->dmetric[type].value = mvalue;
+ ospf->dmetric[type].type = mtype;
+ ospf->dmetric[type].value = mvalue;
zclient_redistribute_set (zclient, type);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_info ("Redistribute[%s]: Start Type[%d], Metric[%d]",
LOOKUP (ospf_redistributed_proto, type),
- metric_type (type), metric_value (type));
+ metric_type (ospf, type), metric_value (ospf, type));
- ospf_asbr_status_update (++ospf_top->redistribute);
+ ospf_asbr_status_update (ospf, ++ospf->redistribute);
return CMD_SUCCESS;
}
@@ -522,6 +514,8 @@ ospf_redistribute_set (int type, int mtype, int mvalue)
int
ospf_redistribute_unset (int type)
{
+ struct ospf *ospf = ospf_top;
+
if (type == zclient->redist_default)
return CMD_SUCCESS;
@@ -534,13 +528,13 @@ ospf_redistribute_unset (int type)
zlog_info ("Redistribute[%s]: Stop",
LOOKUP (ospf_redistributed_proto, type));
- ospf_top->dmetric[type].type = -1;
- ospf_top->dmetric[type].value = -1;
+ ospf->dmetric[type].type = -1;
+ ospf->dmetric[type].value = -1;
/* Remove the routes from OSPF table. */
ospf_redistribute_withdraw (type);
- ospf_asbr_status_update (--ospf_top->redistribute);
+ ospf_asbr_status_update (ospf, --ospf->redistribute);
return CMD_SUCCESS;
}
@@ -548,48 +542,50 @@ ospf_redistribute_unset (int type)
int
ospf_redistribute_default_set (int originate, int mtype, int mvalue)
{
+ struct ospf *ospf = ospf_top;
+
int force = 0;
if (ospf_is_type_redistributed (DEFAULT_ROUTE))
{
- if (mtype != ospf_top->dmetric[DEFAULT_ROUTE].type)
+ if (mtype != ospf->dmetric[DEFAULT_ROUTE].type)
{
- ospf_top->dmetric[DEFAULT_ROUTE].type = mtype;
+ ospf->dmetric[DEFAULT_ROUTE].type = mtype;
force = 1;
}
- if (mvalue != ospf_top->dmetric[DEFAULT_ROUTE].value)
+ if (mvalue != ospf->dmetric[DEFAULT_ROUTE].value)
{
force = 1;
- ospf_top->dmetric[DEFAULT_ROUTE].value = mvalue;
+ ospf->dmetric[DEFAULT_ROUTE].value = mvalue;
}
- ospf_external_lsa_refresh_default ();
+ ospf_external_lsa_refresh_default (ospf);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_info ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
LOOKUP (ospf_redistributed_proto, DEFAULT_ROUTE),
- metric_type (DEFAULT_ROUTE),
- metric_value (DEFAULT_ROUTE));
+ metric_type (ospf, DEFAULT_ROUTE),
+ metric_value (ospf, DEFAULT_ROUTE));
return CMD_SUCCESS;
}
- ospf_top->default_originate = originate;
- ospf_top->dmetric[DEFAULT_ROUTE].type = mtype;
- ospf_top->dmetric[DEFAULT_ROUTE].value = mvalue;
+ ospf->default_originate = originate;
+ ospf->dmetric[DEFAULT_ROUTE].type = mtype;
+ ospf->dmetric[DEFAULT_ROUTE].value = mvalue;
zclient_redistribute_default_set (zclient);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_info ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
- metric_type (DEFAULT_ROUTE), metric_value (DEFAULT_ROUTE));
-
+ metric_type (ospf, DEFAULT_ROUTE),
+ metric_value (ospf, DEFAULT_ROUTE));
- if (ospf_top->router_id.s_addr == 0)
- ospf_top->external_origin |= (1 << DEFAULT_ROUTE);
+ if (ospf->router_id.s_addr == 0)
+ ospf->external_origin |= (1 << DEFAULT_ROUTE);
else
thread_add_timer (master, ospf_default_originate_timer,
- &ospf_top->default_originate, 1);
+ &ospf->default_originate, 1);
- ospf_asbr_status_update (++ospf_top->redistribute);
+ ospf_asbr_status_update (ospf, ++ospf->redistribute);
return CMD_SUCCESS;
}
@@ -597,19 +593,21 @@ ospf_redistribute_default_set (int originate, int mtype, int mvalue)
int
ospf_redistribute_default_unset ()
{
+ struct ospf *ospf = ospf_top;
+
if (!ospf_is_type_redistributed (DEFAULT_ROUTE))
return CMD_SUCCESS;
- ospf_top->default_originate = DEFAULT_ORIGINATE_NONE;
- ospf_top->dmetric[DEFAULT_ROUTE].type = -1;
- ospf_top->dmetric[DEFAULT_ROUTE].value = -1;
+ ospf->default_originate = DEFAULT_ORIGINATE_NONE;
+ ospf->dmetric[DEFAULT_ROUTE].type = -1;
+ ospf->dmetric[DEFAULT_ROUTE].value = -1;
zclient_redistribute_default_unset (zclient);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_info ("Redistribute[DEFAULT]: Stop");
- ospf_asbr_status_update (--ospf_top->redistribute);
+ ospf_asbr_status_update (ospf, --ospf->redistribute);
return CMD_SUCCESS;
}
@@ -617,6 +615,8 @@ ospf_redistribute_default_unset ()
int
ospf_external_lsa_originate_check (struct external_info *ei)
{
+ struct ospf *ospf = ospf_top;
+
/* If prefix is multicast, then do not originate LSA. */
if (IN_MULTICAST (htonl (ei->p.prefix.s_addr)))
{
@@ -627,7 +627,7 @@ ospf_external_lsa_originate_check (struct external_info *ei)
/* Take care of default-originate. */
if (is_prefix_default (&ei->p))
- if (ospf_top->default_originate == DEFAULT_ORIGINATE_NONE)
+ if (ospf->default_originate == DEFAULT_ORIGINATE_NONE)
{
zlog_info ("LSA[Type5:0.0.0.0]: Not originate AS-exntenal-LSA "
"for default");
@@ -639,21 +639,26 @@ ospf_external_lsa_originate_check (struct external_info *ei)
/* If connected prefix is OSPF enable interface, then do not announce. */
int
-ospf_distribute_check_connected (struct external_info *ei)
+ospf_distribute_check_connected (struct ospf *ospf,
+ struct external_info *ei)
{
struct route_node *rn;
- for (rn = route_top (ospf_top->networks); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
if (rn->info != NULL)
if (prefix_match (&rn->p, (struct prefix *)&ei->p))
- return 0;
+ {
+ route_unlock_node (rn);
+ return 0;
+ }
return 1;
}
/* return 1 if external LSA must be originated, 0 otherwise */
int
-ospf_redistribute_check (struct external_info *ei, int *changed)
+ospf_redistribute_check (struct ospf *ospf,
+ struct external_info *ei, int *changed)
{
struct route_map_set_values save_values;
struct prefix_ipv4 *p = &ei->p;
@@ -666,7 +671,8 @@ ospf_redistribute_check (struct external_info *ei, int *changed)
return 0;
/* Take care connected route. */
- if (type == ZEBRA_ROUTE_CONNECT && !ospf_distribute_check_connected (ei))
+ if (type == ZEBRA_ROUTE_CONNECT &&
+ !ospf_distribute_check_connected (ospf, ei))
return 0;
if (!DEFAULT_ROUTE_TYPE (type) && DISTRIBUTE_NAME (type))
@@ -743,6 +749,7 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
struct in_addr nexthop;
struct prefix_ipv4 p;
struct external_info *ei;
+ struct ospf *ospf = ospf_top;
s = zclient->ibuf;
ifindex = 0;
@@ -779,25 +786,26 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
{
ei = ospf_external_info_add (api.type, p, ifindex, nexthop);
- if (ospf_top->router_id.s_addr == 0)
+ if (ospf->router_id.s_addr == 0)
/* Set flags to generate AS-external-LSA originate event
for each redistributed protocols later. */
- ospf_top->external_origin |= (1 << api.type);
+ ospf->external_origin |= (1 << api.type);
else
{
if (ei)
{
if (is_prefix_default (&p))
- ospf_external_lsa_refresh_default ();
+ ospf_external_lsa_refresh_default (ospf);
else
{
struct ospf_lsa *current;
- current = ospf_external_info_find_lsa (&ei->p);
+ current = ospf_external_info_find_lsa (ospf, &ei->p);
if (!current)
- ospf_external_lsa_originate (ei);
+ ospf_external_lsa_originate (ospf, ei);
else if (IS_LSA_MAXAGE (current))
- ospf_external_lsa_refresh (current, ei, LSA_REFRESH_FORCE);
+ ospf_external_lsa_refresh (ospf, current,
+ ei, LSA_REFRESH_FORCE);
else
zlog_warn ("ospf_zebra_read_ipv4() : %s already exists",
inet_ntoa (p.prefix));
@@ -809,9 +817,9 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
{
ospf_external_info_delete (api.type, p);
if ( !is_prefix_default (&p))
- ospf_external_lsa_flush (api.type, &p, ifindex, nexthop);
+ ospf_external_lsa_flush (ospf, api.type, &p, ifindex, nexthop);
else
- ospf_external_lsa_refresh_default ();
+ ospf_external_lsa_refresh_default (ospf);
}
return 0;
@@ -819,7 +827,7 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
int
-ospf_distribute_list_out_set (int type, char *name)
+ospf_distribute_list_out_set (struct ospf *ospf, int type, char *name)
{
/* Lookup access-list for distribute-list. */
DISTRIBUTE_LIST (type) = access_list_lookup (AFI_IP, name);
@@ -833,17 +841,17 @@ ospf_distribute_list_out_set (int type, char *name)
/* If access-list have been set, schedule update timer. */
if (DISTRIBUTE_LIST (type))
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
return CMD_SUCCESS;
}
int
-ospf_distribute_list_out_unset (int type, char *name)
+ospf_distribute_list_out_unset (struct ospf *ospf, int type, char *name)
{
/* Schedule update timer. */
if (DISTRIBUTE_LIST (type))
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
/* Unset distribute-list. */
DISTRIBUTE_LIST (type) = NULL;
@@ -866,11 +874,12 @@ ospf_distribute_list_update_timer (struct thread *thread)
struct route_table *rt;
struct ospf_lsa *lsa;
u_char type;
+ struct ospf *ospf = ospf_top;
type = (int) THREAD_ARG (thread);
rt = EXTERNAL_INFO (type);
- ospf_top->t_distribute_update = NULL;
+ ospf->t_distribute_update = NULL;
zlog_info ("Zebra[Redistribute]: distribute-list update timer fired!");
@@ -880,11 +889,11 @@ ospf_distribute_list_update_timer (struct thread *thread)
if ((ei = rn->info) != NULL)
{
if (is_prefix_default (&ei->p))
- ospf_external_lsa_refresh_default ();
- else if ((lsa = ospf_external_info_find_lsa (&ei->p)))
- ospf_external_lsa_refresh (lsa, ei, LSA_REFRESH_IF_CHANGED);
+ ospf_external_lsa_refresh_default (ospf);
+ else if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p)))
+ ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_IF_CHANGED);
else
- ospf_external_lsa_originate (ei);
+ ospf_external_lsa_originate (ospf, ei);
}
return 0;
}
@@ -893,49 +902,45 @@ ospf_distribute_list_update_timer (struct thread *thread)
/* Update distribute-list and set timer to apply access-list. */
void
-ospf_distribute_list_update (int type)
+ospf_distribute_list_update (struct ospf *ospf, int type)
{
struct route_table *rt;
- zlog_info ("ospf_distribute_list_update(): start");
-
/* External info does not exist. */
if (!(rt = EXTERNAL_INFO (type)))
return;
/* If exists previously invoked thread, then cancel it. */
- if (ospf_top->t_distribute_update)
- OSPF_TIMER_OFF (ospf_top->t_distribute_update);
+ if (ospf->t_distribute_update)
+ OSPF_TIMER_OFF (ospf->t_distribute_update);
/* Set timer. */
- ospf_top->t_distribute_update =
+ ospf->t_distribute_update =
thread_add_timer (master, ospf_distribute_list_update_timer,
(void *) type, OSPF_DISTRIBUTE_UPDATE_DELAY);
-
- zlog_info ("ospf_distribute_list_update(): stop");
}
/* If access-list is updated, apply some check. */
void
ospf_filter_update (struct access_list *access)
{
+ struct ospf *ospf = ospf_top;
int type;
int abr_inv = 0;
struct ospf_area *area;
listnode node;
/* If OSPF instatnce does not exist, return right now. */
- if (!ospf_top)
+ if (ospf == NULL)
return;
-
/* Update distribute-list, and apply filter. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
{
if (ROUTEMAP (type) != NULL)
{
/* if route-map is not NULL it may be using this access list */
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
continue;
}
@@ -956,12 +961,12 @@ ospf_filter_update (struct access_list *access)
/* Schedule distribute-list update timer. */
if (DISTRIBUTE_LIST (type) == NULL ||
strcmp (DISTRIBUTE_NAME (type), access->name) == 0)
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
}
}
/* Update Area access-list. */
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
{
if (EXPORT_NAME (area))
@@ -979,7 +984,7 @@ ospf_filter_update (struct access_list *access)
/* Schedule ABR tasks -- this will be changed -- takada. */
if (OSPF_IS_ABR && abr_inv)
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
@@ -1007,6 +1012,7 @@ ospf_distance_set (struct vty *vty, char *distance_str, char *ip_str,
u_char distance;
struct route_node *rn;
struct ospf_distance *odistance;
+ struct ospf *ospf = ospf_top;
ret = str2prefix_ipv4 (ip_str, &p);
if (ret == 0)
@@ -1018,7 +1024,7 @@ ospf_distance_set (struct vty *vty, char *distance_str, char *ip_str,
distance = atoi (distance_str);
/* Get OSPF distance node. */
- rn = route_node_get (ospf_top->distance_table, (struct prefix *) &p);
+ rn = route_node_get (ospf->distance_table, (struct prefix *) &p);
if (rn->info)
{
odistance = rn->info;
@@ -1054,6 +1060,7 @@ ospf_distance_unset (struct vty *vty, char *distance_str, char *ip_str,
u_char distance;
struct route_node *rn;
struct ospf_distance *odistance;
+ struct ospf *ospf = ospf_top;
ret = str2prefix_ipv4 (ip_str, &p);
if (ret == 0)
@@ -1064,7 +1071,7 @@ ospf_distance_unset (struct vty *vty, char *distance_str, char *ip_str,
distance = atoi (distance_str);
- rn = route_node_lookup (ospf_top->distance_table, (struct prefix *)&p);
+ rn = route_node_lookup (ospf->distance_table, (struct prefix *)&p);
if (! rn)
{
vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
@@ -1085,12 +1092,12 @@ ospf_distance_unset (struct vty *vty, char *distance_str, char *ip_str,
}
void
-ospf_distance_reset ()
+ospf_distance_reset (struct ospf *ospf)
{
struct route_node *rn;
struct ospf_distance *odistance;
- for (rn = route_top (ospf_top->distance_table); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
if ((odistance = rn->info) != NULL)
{
if (odistance->access_list)
@@ -1104,58 +1111,26 @@ ospf_distance_reset ()
u_char
ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or)
{
-#if 0
- struct route_node *rn;
- struct ospf_distance *odistance;
- struct access_list *alist;
- struct prefix_ipv4 q;
-
- memset (&q, 0, sizeof (struct prefix_ipv4));
- q.family = AF_INET;
- /* q.prefix = */
- q.prefixlen = IPV4_MAX_BITLEN;
-#endif /* 0 */
+ struct ospf *ospf = ospf_top;
- if (! ospf_top)
+ if (ospf == NULL)
return 0;
-#if 0
- rn = route_node_match (ospf_top->distance_table, (struct prefix *) &q);
- if (rn)
- {
- odistance = rn->info;
- route_unlock_node (rn);
-
- if (odistance->access_list)
- {
- alist = access_list_lookup (AFI_IP, odistance->access_list);
- if (alist == NULL)
- return 0;
- if (access_list_apply (alist, (struct prefix *) p) == FILTER_DENY)
- return 0;
-
- return odistance->distance;
- }
- else
- return odistance->distance;
- }
-#endif /* 0 */
-
- if (ospf_top->distance_intra)
+ if (ospf->distance_intra)
if (or->path_type == OSPF_PATH_INTRA_AREA)
- return ospf_top->distance_intra;
+ return ospf->distance_intra;
- if (ospf_top->distance_inter)
+ if (ospf->distance_inter)
if (or->path_type == OSPF_PATH_INTER_AREA)
- return ospf_top->distance_inter;
+ return ospf->distance_inter;
- if (ospf_top->distance_external)
+ if (ospf->distance_external)
if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL
|| or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
- return ospf_top->distance_external;
+ return ospf->distance_external;
- if (ospf_top->distance_all)
- return ospf_top->distance_all;
+ if (ospf->distance_all)
+ return ospf->distance_all;
return 0;
}
diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h
index 5dbf5739..8c00c9d7 100644
--- a/ospfd/ospf_zebra.h
+++ b/ospfd/ospf_zebra.h
@@ -50,14 +50,14 @@ void ospf_zebra_delete_discard (struct prefix_ipv4 *);
int ospf_default_originate_timer (struct thread *);
-int ospf_redistribute_check (struct external_info *, int *);
-int ospf_distribute_check_connected (struct external_info *);
-void ospf_distribute_list_update (int);
+int ospf_redistribute_check (struct ospf *, struct external_info *, int *);
+int ospf_distribute_check_connected (struct ospf *, struct external_info *);
+void ospf_distribute_list_update (struct ospf *, int);
int ospf_is_type_redistributed (int);
int ospf_redistribute_unset (int);
-void ospf_distance_reset ();
+void ospf_distance_reset (struct ospf *);
u_char ospf_distance_apply (struct prefix_ipv4 *, struct ospf_route *);
struct vty;
@@ -66,8 +66,8 @@ int ospf_redistribute_set (int, int, int);
int ospf_redistribute_unset (int);
int ospf_redistribute_default_set (int, int, int);
int ospf_redistribute_default_unset ();
-int ospf_distribute_list_out_set (int, char *);
-int ospf_distribute_list_out_unset (int, char *);
+int ospf_distribute_list_out_set (struct ospf *, int, char *);
+int ospf_distribute_list_out_unset (struct ospf *, int, char *);
void ospf_routemap_set (int, char *);
void ospf_routemap_unset (int);
int ospf_distance_set (struct vty *, char *, char *, char *);
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index e7de8eab..6064a138 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -58,8 +58,8 @@ struct ospf *ospf_top;
extern struct zclient *zclient;
-void ospf_remove_vls_through_area (struct ospf_area *);
-void ospf_network_free (struct ospf_network *);
+void ospf_remove_vls_through_area (struct ospf *, struct ospf_area *);
+void ospf_network_free (struct ospf *, struct ospf_network *);
void ospf_area_free (struct ospf_area *);
void ospf_network_run (struct ospf *, struct prefix *, struct ospf_area *);
@@ -93,29 +93,29 @@ ospf_router_id_get (list if_list)
#define OSPF_EXTERNAL_LSA_ORIGINATE_DELAY 1
void
-ospf_router_id_update ()
+ospf_router_id_update (struct ospf *ospf)
{
- listnode node;
struct in_addr router_id, router_id_old;
+ listnode node;
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("Router-ID[OLD:%s]: Update",inet_ntoa (ospf_top->router_id));
+ zlog_info ("Router-ID[OLD:%s]: Update", inet_ntoa (ospf->router_id));
- router_id_old = ospf_top->router_id;
+ router_id_old = ospf->router_id;
- if (ospf_top->router_id_static.s_addr != 0)
- router_id = ospf_top->router_id_static;
+ if (ospf->router_id_static.s_addr != 0)
+ router_id = ospf->router_id_static;
else
- router_id = ospf_router_id_get (ospf_top->oiflist);
+ router_id = ospf_router_id_get (ospf->oiflist);
- ospf_top->router_id = router_id;
+ ospf->router_id = router_id;
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("Router-ID[NEW:%s]: Update", inet_ntoa (ospf_top->router_id));
+ zlog_info ("Router-ID[NEW:%s]: Update", inet_ntoa (ospf->router_id));
if (!IPV4_ADDR_SAME (&router_id_old, &router_id))
{
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
struct ospf_interface *oi = getdata (node);
@@ -124,23 +124,23 @@ ospf_router_id_update ()
}
/* If AS-external-LSA is queued, then flush those LSAs. */
- if (router_id_old.s_addr == 0 && ospf_top->external_origin)
+ if (router_id_old.s_addr == 0 && ospf->external_origin)
{
int type;
/* Originate each redistributed external route. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
- if (ospf_top->external_origin & (1 << type))
+ if (ospf->external_origin & (1 << type))
thread_add_event (master, ospf_external_lsa_originate_timer,
- NULL, type);
+ ospf, type);
/* Originate Deafult. */
- if (ospf_top->external_origin & (1 << ZEBRA_ROUTE_MAX))
+ if (ospf->external_origin & (1 << ZEBRA_ROUTE_MAX))
thread_add_event (master, ospf_default_originate_timer,
- &ospf_top->default_originate, 0);
+ &ospf->default_originate, 0);
- ospf_top->external_origin = 0;
+ ospf->external_origin = 0;
}
- OSPF_TIMER_ON (ospf_top->t_router_lsa_update,
+ OSPF_TIMER_ON (ospf->t_router_lsa_update,
ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
}
}
@@ -148,11 +148,13 @@ ospf_router_id_update ()
int
ospf_router_id_update_timer (struct thread *thread)
{
+ struct ospf *ospf = ospf_top;
+
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Router-ID: Update timer fired!");
- ospf_top->t_router_id_update = NULL;
- ospf_router_id_update ();
+ ospf->t_router_id_update = NULL;
+ ospf_router_id_update (ospf);
return 0;
}
@@ -213,7 +215,7 @@ ospf_new ()
new->maxage_lsa = list_new ();
new->t_maxage_walker =
thread_add_timer (master, ospf_lsa_maxage_walker,
- NULL, OSPF_LSA_MAXAGE_CHECK_INTERVAL);
+ new, OSPF_LSA_MAXAGE_CHECK_INTERVAL);
/* Distance table init. */
new->distance_table = route_table_init ();
@@ -235,19 +237,23 @@ ospf_new ()
struct ospf *
ospf_get ()
{
- if (ospf_top != NULL)
- return ospf_top;
+ struct ospf *ospf = ospf_top;
- ospf_top = ospf_new ();
+ if (ospf != NULL)
+ return ospf;
- if (ospf_top->router_id_static.s_addr == 0)
- ospf_router_id_update ();
+ ospf = ospf_new ();
+
+ if (ospf->router_id_static.s_addr == 0)
+ ospf_router_id_update (ospf);
#ifdef HAVE_OPAQUE_LSA
- ospf_opaque_type11_lsa_init (ospf_top);
+ ospf_opaque_type11_lsa_init (ospf);
#endif /* HAVE_OPAQUE_LSA */
- return ospf_top;
+ ospf_top = ospf;
+
+ return ospf;
}
void
@@ -255,6 +261,7 @@ ospf_finish (struct ospf *ospf)
{
struct route_node *rn;
struct ospf_nbr_nbma *nbr_nbma;
+ struct ospf_lsa *lsa;
listnode node;
int i;
@@ -271,7 +278,7 @@ ospf_finish (struct ospf *ospf)
struct ospf_area *area = getdata (node);
nextnode (node);
- ospf_remove_vls_through_area (area);
+ ospf_remove_vls_through_area (ospf, area);
}
for (node = listhead (ospf->vlinks); node; )
@@ -279,7 +286,7 @@ ospf_finish (struct ospf *ospf)
struct ospf_vl_data *vl_data = node->data;
nextnode (node);
- ospf_vl_delete (vl_data);
+ ospf_vl_delete (ospf, vl_data);
}
list_delete (ospf->vlinks);
@@ -324,7 +331,7 @@ ospf_finish (struct ospf *ospf)
if ((network = rn->info) != NULL)
{
- ospf_network_free (network);
+ ospf_network_free (ospf, network);
rn->info = NULL;
route_unlock_node (rn);
}
@@ -356,11 +363,12 @@ ospf_finish (struct ospf *ospf)
close (ospf->fd);
#ifdef HAVE_OPAQUE_LSA
- foreach_lsa (OPAQUE_AS_LSDB (ospf), ospf_top->lsdb, 0,
- ospf_lsa_discard_callback);
+ LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
+ ospf_discard_from_db (ospf, ospf->lsdb, lsa);
#endif /* HAVE_OPAQUE_LSA */
- foreach_lsa (EXTERNAL_LSDB (ospf), ospf->lsdb, 0,
- ospf_lsa_discard_callback);
+ LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
+ ospf_discard_from_db (ospf, ospf->lsdb, lsa);
+
ospf_lsdb_delete_all (ospf->lsdb);
ospf_lsdb_free (ospf->lsdb);
@@ -409,7 +417,7 @@ ospf_finish (struct ospf *ospf)
route_unlock_node (rn);
}
- ospf_distance_reset ();
+ ospf_distance_reset (ospf);
route_table_finish (ospf->distance_table);
XFREE (MTYPE_OSPF_TOP, ospf);
@@ -420,14 +428,14 @@ ospf_finish (struct ospf *ospf)
/* allocate new OSPF Area object */
struct ospf_area *
-ospf_area_new (struct in_addr area_id)
+ospf_area_new (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *new;
/* Allocate new config_network. */
new = XCALLOC (MTYPE_OSPF_AREA, sizeof (struct ospf_area));
- new->top = ospf_top;
+ new->ospf = ospf;
new->area_id = area_id;
@@ -449,7 +457,7 @@ ospf_area_new (struct in_addr area_id)
new->ranges = route_table_init ();
if (area_id.s_addr == OSPF_AREA_BACKBONE)
- ospf_top->backbone = new;
+ ospf->backbone = new;
return new;
}
@@ -457,21 +465,28 @@ ospf_area_new (struct in_addr area_id)
void
ospf_area_free (struct ospf_area *area)
{
+ struct route_node *rn;
+ struct ospf_lsa *lsa;
+
/* Free LSDBs. */
- foreach_lsa (ROUTER_LSDB (area), area->lsdb, 0, ospf_lsa_discard_callback);
- foreach_lsa (NETWORK_LSDB (area), area->lsdb, 0, ospf_lsa_discard_callback);
- foreach_lsa (SUMMARY_LSDB (area), area->lsdb, 0, ospf_lsa_discard_callback);
- foreach_lsa (ASBR_SUMMARY_LSDB (area), area->lsdb, 0,
- ospf_lsa_discard_callback);
+ LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
+ LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
+ LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
+ LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
#ifdef HAVE_NSSA
- foreach_lsa (NSSA_LSDB (area), area->lsdb, 0, ospf_lsa_discard_callback);
+ LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
#endif /* HAVE_NSSA */
#ifdef HAVE_OPAQUE_LSA
- foreach_lsa (OPAQUE_AREA_LSDB (area), area->lsdb, 0,
- ospf_lsa_discard_callback);
- foreach_lsa (OPAQUE_LINK_LSDB (area), area->lsdb, 0,
- ospf_lsa_discard_callback);
+ LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
+ LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
+ ospf_discard_from_db (area->ospf, area->lsdb, lsa);
#endif /* HAVE_OPAQUE_LSA */
ospf_lsdb_delete_all (area->lsdb);
@@ -495,17 +510,17 @@ ospf_area_free (struct ospf_area *area)
OSPF_TIMER_OFF (area->t_router_lsa_self);
if (OSPF_IS_AREA_BACKBONE (area))
- ospf_top->backbone = NULL;
+ area->ospf->backbone = NULL;
XFREE (MTYPE_OSPF_AREA, area);
}
void
-ospf_area_check_free (struct in_addr area_id)
+ospf_area_check_free (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area &&
listcount (area->oiflist) == 0 &&
area->ranges->top == NULL &&
@@ -517,35 +532,35 @@ ospf_area_check_free (struct in_addr area_id)
IMPORT_NAME (area) == NULL &&
area->auth_type == OSPF_AUTH_NULL)
{
- listnode_delete (ospf_top->areas, area);
+ listnode_delete (ospf->areas, area);
ospf_area_free (area);
}
}
struct ospf_area *
-ospf_area_get (struct in_addr area_id, int format)
+ospf_area_get (struct ospf *ospf, struct in_addr area_id, int format)
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (!area)
{
- area = ospf_area_new (area_id);
+ area = ospf_area_new (ospf, area_id);
area->format = format;
- listnode_add_sort (ospf_top->areas, area);
- ospf_check_abr_status ();
+ listnode_add_sort (ospf->areas, area);
+ ospf_check_abr_status (ospf);
}
return area;
}
struct ospf_area *
-ospf_area_lookup_by_area_id (struct in_addr area_id)
+ospf_area_lookup_by_area_id (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
listnode node;
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -583,10 +598,10 @@ ospf_network_new (struct in_addr area_id, int format)
}
void
-ospf_network_free (struct ospf_network *network)
+ospf_network_free (struct ospf *ospf, struct ospf_network *network)
{
- ospf_area_check_free (network->area_id);
- ospf_schedule_abr_task ();
+ ospf_area_check_free (ospf, network->area_id);
+ ospf_schedule_abr_task (ospf);
XFREE (MTYPE_OSPF_NETWORK, network);
}
@@ -609,7 +624,7 @@ ospf_network_set (struct ospf *ospf, struct prefix_ipv4 *p,
}
rn->info = network = ospf_network_new (area_id, ret);
- area = ospf_area_get (area_id, ret);
+ area = ospf_area_get (ospf, area_id, ret);
/* Run network config now. */
ospf_network_run (ospf, (struct prefix *)p, area);
@@ -620,12 +635,12 @@ ospf_network_set (struct ospf *ospf, struct prefix_ipv4 *p,
for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
rn; rn = route_next (rn))
if ((ei = rn->info) != NULL)
- if (ospf_external_info_find_lsa (&ei->p))
- if (!ospf_distribute_check_connected (ei))
- ospf_external_lsa_flush (ei->type, &ei->p,
+ if (ospf_external_info_find_lsa (ospf, &ei->p))
+ if (!ospf_distribute_check_connected (ospf, ei))
+ ospf_external_lsa_flush (ospf, ei->type, &ei->p,
ei->ifindex, ei->nexthop);
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return 1;
}
@@ -646,11 +661,11 @@ ospf_network_unset (struct ospf *ospf, struct prefix_ipv4 *p,
if (!IPV4_ADDR_SAME (&area_id, &network->area_id))
return 0;
- ospf_network_free (rn->info);
+ ospf_network_free (ospf, rn->info);
rn->info = NULL;
route_unlock_node (rn);
- ospf_if_update ();
+ ospf_if_update (ospf);
/* Update connected redistribute. */
if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
@@ -658,9 +673,9 @@ ospf_network_unset (struct ospf *ospf, struct prefix_ipv4 *p,
for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
rn; rn = route_next (rn))
if ((ei = rn->info) != NULL)
- if (!ospf_external_info_find_lsa (&ei->p))
- if (ospf_distribute_check_connected (ei))
- ospf_external_lsa_originate (ei);
+ if (!ospf_external_info_find_lsa (ospf, &ei->p))
+ if (ospf_distribute_check_connected (ospf, ei))
+ ospf_external_lsa_originate (ospf, ei);
return 1;
}
@@ -705,14 +720,14 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
addr = co->address;
if (p->family == co->address->family &&
- ! ospf_if_is_configured (&(addr->u.prefix4)))
+ ! ospf_if_is_configured (ospf, &(addr->u.prefix4)))
if ((if_is_pointopoint (ifp) &&
IPV4_ADDR_SAME (&(addr->u.prefix4), &(p->u.prefix4))) ||
prefix_match (p, addr))
{
struct ospf_interface *oi;
- oi = ospf_if_new (ifp, co->address);
+ oi = ospf_if_new (ospf, ifp, co->address);
oi->connected = co;
oi->nbr_self->address = *oi->address;
@@ -731,11 +746,11 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
ospf_nbr_add_self (oi);
/* Make sure pseudo neighbor's router_id. */
- oi->nbr_self->router_id = ospf_top->router_id;
+ oi->nbr_self->router_id = ospf->router_id;
oi->nbr_self->src = oi->address->u.prefix4;
/* Relate ospf interface to ospf instance. */
- oi->ospf = ospf_top;
+ oi->ospf = ospf;
/* update network type as interface flag */
/* If network type is specified previously,
@@ -799,7 +814,7 @@ ospf_ls_upd_queue_empty (struct ospf_interface *oi)
}
void
-ospf_if_update ()
+ospf_if_update (struct ospf *ospf)
{
struct route_node *rn;
listnode node;
@@ -807,19 +822,19 @@ ospf_if_update ()
struct ospf_network *network;
struct ospf_area *area;
- if (ospf_top != NULL)
+ if (ospf != NULL)
{
/* Update Router ID scheduled. */
- if (ospf_top->router_id_static.s_addr == 0)
- if (ospf_top->t_router_id_update == NULL)
+ if (ospf->router_id_static.s_addr == 0)
+ if (ospf->t_router_id_update == NULL)
{
- ospf_top->t_router_id_update =
+ ospf->t_router_id_update =
thread_add_timer (master, ospf_router_id_update_timer, NULL,
OSPF_ROUTER_ID_UPDATE_DELAY);
}
/* Find interfaces that not configured already. */
- for (node = listhead (ospf_top->oiflist); node; node = next)
+ for (node = listhead (ospf->oiflist); node; node = next)
{
int found = 0;
struct ospf_interface *oi = getdata (node);
@@ -830,7 +845,7 @@ ospf_if_update ()
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
- for (rn = route_top (ospf_top->networks); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
{
if (rn->info == NULL)
continue;
@@ -851,28 +866,28 @@ ospf_if_update ()
}
/* Run each interface. */
- for (rn = route_top (ospf_top->networks); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
if (rn->info != NULL)
{
network = (struct ospf_network *) rn->info;
- area = ospf_area_get (network->area_id, network->format);
- ospf_network_run (ospf_top, &rn->p, area);
+ area = ospf_area_get (ospf, network->area_id, network->format);
+ ospf_network_run (ospf, &rn->p, area);
}
}
}
void
-ospf_remove_vls_through_area (struct ospf_area *area)
+ospf_remove_vls_through_area (struct ospf *ospf, struct ospf_area *area)
{
listnode node, next;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf_top->vlinks); node; node = next)
+ for (node = listhead (ospf->vlinks); node; node = next)
{
next = node->next;
if ((vl_data = getdata (node)) != NULL)
if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
- ospf_vl_delete (vl_data);
+ ospf_vl_delete (ospf, vl_data);
}
}
@@ -944,31 +959,31 @@ ospf_area_type_set (struct ospf_area *area, int type)
}
ospf_router_lsa_timer_add (area);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (area->ospf);
}
int
-ospf_area_shortcut_set (struct ospf_area *area, int mode)
+ospf_area_shortcut_set (struct ospf *ospf, struct ospf_area *area, int mode)
{
if (area->shortcut_configured == mode)
return 0;
area->shortcut_configured = mode;
ospf_router_lsa_timer_add (area);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
- ospf_area_check_free (area->area_id);
+ ospf_area_check_free (ospf, area->area_id);
return 1;
}
int
-ospf_area_shortcut_unset (struct ospf_area *area)
+ospf_area_shortcut_unset (struct ospf *ospf, struct ospf_area *area)
{
area->shortcut_configured = OSPF_SHORTCUT_DEFAULT;
ospf_router_lsa_timer_add (area);
- ospf_area_check_free (area->area_id);
- ospf_schedule_abr_task ();
+ ospf_area_check_free (ospf, area->area_id);
+ ospf_schedule_abr_task (ospf);
return 1;
}
@@ -996,7 +1011,7 @@ ospf_area_stub_set (struct ospf *ospf, struct in_addr area_id)
struct ospf_area *area;
int format = OSPF_AREA_ID_FORMAT_DECIMAL;
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
if (ospf_area_vlink_count (ospf, area))
return 0;
@@ -1011,14 +1026,14 @@ ospf_area_stub_unset (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 1;
if (area->external_routing == OSPF_AREA_STUB)
ospf_area_type_set (area, OSPF_AREA_DEFAULT);
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return 1;
}
@@ -1029,7 +1044,7 @@ ospf_area_no_summary_set (struct ospf *ospf, struct in_addr area_id)
struct ospf_area *area;
int format = OSPF_AREA_ID_FORMAT_DECIMAL;
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
area->no_summary = 1;
return 1;
@@ -1040,12 +1055,12 @@ ospf_area_no_summary_unset (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 0;
area->no_summary = 0;
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return 1;
}
@@ -1056,7 +1071,7 @@ ospf_area_nssa_set (struct ospf *ospf, struct in_addr area_id)
struct ospf_area *area;
int format = OSPF_AREA_ID_FORMAT_DECIMAL;
- area = ospf_area_get (area_id, format);
+ area = ospf_area_get (ospf, area_id, format);
if (ospf_area_vlink_count (ospf, area))
return 0;
@@ -1074,7 +1089,7 @@ ospf_area_nssa_unset (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 0;
@@ -1084,7 +1099,7 @@ ospf_area_nssa_unset (struct ospf *ospf, struct in_addr area_id)
ospf_area_type_set (area, OSPF_AREA_DEFAULT);
}
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return 1;
}
@@ -1095,7 +1110,7 @@ ospf_area_nssa_translator_role_set (struct ospf *ospf, struct in_addr area_id,
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 0;
@@ -1110,19 +1125,20 @@ ospf_area_nssa_translator_role_unset (struct ospf *ospf,
{
struct ospf_area *area;
- area = ospf_area_lookup_by_area_id (area_id);
+ area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
return 0;
area->NSSATranslator = OSPF_NSSA_ROLE_CANDIDATE;
- ospf_area_check_free (area_id);
+ ospf_area_check_free (ospf, area_id);
return 1;
}
int
-ospf_area_export_list_set (struct ospf_area *area, char *list_name)
+ospf_area_export_list_set (struct ospf *ospf,
+ struct ospf_area *area, char *list_name)
{
struct access_list *list;
list = access_list_lookup (AFI_IP, list_name);
@@ -1133,13 +1149,13 @@ ospf_area_export_list_set (struct ospf_area *area, char *list_name)
free (EXPORT_NAME (area));
EXPORT_NAME (area) = strdup (list_name);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
return 1;
}
int
-ospf_area_export_list_unset (struct ospf_area * area)
+ospf_area_export_list_unset (struct ospf *ospf, struct ospf_area * area)
{
EXPORT_LIST (area) = 0;
@@ -1149,15 +1165,16 @@ ospf_area_export_list_unset (struct ospf_area * area)
EXPORT_NAME (area) = NULL;
- ospf_area_check_free (area->area_id);
+ ospf_area_check_free (ospf, area->area_id);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
return 1;
}
int
-ospf_area_import_list_set (struct ospf_area *area, char *name)
+ospf_area_import_list_set (struct ospf *ospf,
+ struct ospf_area *area, char *name)
{
struct access_list *list;
list = access_list_lookup (AFI_IP, name);
@@ -1168,13 +1185,13 @@ ospf_area_import_list_set (struct ospf_area *area, char *name)
free (IMPORT_NAME (area));
IMPORT_NAME (area) = strdup (name);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
return 1;
}
int
-ospf_area_import_list_unset (struct ospf_area * area)
+ospf_area_import_list_unset (struct ospf *ospf, struct ospf_area * area)
{
IMPORT_LIST (area) = 0;
@@ -1182,9 +1199,9 @@ ospf_area_import_list_unset (struct ospf_area * area)
free (IMPORT_NAME (area));
IMPORT_NAME (area) = NULL;
- ospf_area_check_free (area->area_id);
+ ospf_area_check_free (ospf, area->area_id);
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
return 1;
}
@@ -1357,7 +1374,7 @@ ospf_nbr_nbma_add (struct ospf_nbr_nbma *nbr_nbma,
}
void
-ospf_nbr_nbma_if_update (struct ospf_interface *oi)
+ospf_nbr_nbma_if_update (struct ospf *ospf, struct ospf_interface *oi)
{
struct ospf_nbr_nbma *nbr_nbma;
struct route_node *rn;
@@ -1366,7 +1383,7 @@ ospf_nbr_nbma_if_update (struct ospf_interface *oi)
if (oi->type != OSPF_IFTYPE_NBMA)
return;
- for (rn = route_top (ospf_top->nbr_nbma); rn; rn = route_next (rn))
+ for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
if ((nbr_nbma = rn->info))
if (nbr_nbma->oi == NULL && nbr_nbma->nbr == NULL)
{
@@ -1399,18 +1416,18 @@ ospf_nbr_nbma_lookup (struct ospf *ospf, struct in_addr nbr_addr)
}
struct ospf_nbr_nbma *
-ospf_nbr_nbma_lookup_next (struct in_addr *addr, int first)
+ospf_nbr_nbma_lookup_next (struct ospf *ospf, struct in_addr *addr, int first)
{
#if 0
struct ospf_nbr_nbma *nbr_nbma;
listnode node;
#endif
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
#if 0
- for (node = listhead (ospf_top->nbr_nbma); node; nextnode (node))
+ for (node = listhead (ospf->nbr_nbma); node; nextnode (node))
{
nbr_nbma = getdata (node);
@@ -1555,16 +1572,17 @@ ospf_nbr_nbma_poll_interval_unset (struct ospf *ospf, struct in_addr addr)
void
ospf_prefix_list_update (struct prefix_list *plist)
{
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
listnode node;
int abr_inv = 0;
/* If OSPF instatnce does not exist, return right now. */
- if (!ospf_top)
+ if (ospf == NULL)
return;
/* Update Area prefix-list. */
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -1589,7 +1607,7 @@ ospf_prefix_list_update (struct prefix_list *plist)
/* Schedule ABR tasks. */
if (OSPF_IS_ABR && abr_inv)
- ospf_schedule_abr_task ();
+ ospf_schedule_abr_task (ospf);
}
void
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index a83231b2..81790c8e 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -32,6 +32,11 @@
#define IPPROTO_OSPFIGP 89
#endif /* IPPROTO_OSPFIGP */
+/* IP precedence. */
+#ifndef IPTOS_PREC_INTERNETCONTROL
+#define IPTOS_PREC_INTERNETCONTROL 0xC0
+#endif /* IPTOS_PREC_INTERNETCONTROL */
+
/* VTY port number. */
#define OSPF_VTY_PORT 2604
#define OSPF_VTYSH_PATH "/tmp/.ospfd"
@@ -288,7 +293,7 @@ struct ospf
struct ospf_area
{
/* OSPF instance. */
- struct ospf *top;
+ struct ospf *ospf;
/* Zebra interface list belonging to the area. */
list oiflist;
@@ -456,7 +461,7 @@ struct ospf_nbr_nbma
#define OSPF_TIMER_ON(T,F,V) \
do { \
if (!(T)) \
- (T) = thread_add_timer (master, (F), NULL, (V)); \
+ (T) = thread_add_timer (master, (F), ospf, (V)); \
} while (0)
#define OSPF_AREA_TIMER_ON(T,F,V) \
@@ -482,12 +487,6 @@ struct ospf_nbr_nbma
} \
} while (0)
-#define OSPF_SCHEDULE_MAXAGE(T, F) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), 0, 2); \
- } while (0)
-
/* Messages */
extern struct message ospf_ism_state_msg[];
extern struct message ospf_nsm_state_msg[];
@@ -520,12 +519,12 @@ int ospf_area_no_summary_unset (struct ospf *, struct in_addr);
int ospf_area_nssa_set (struct ospf *, struct in_addr);
int ospf_area_nssa_unset (struct ospf *, struct in_addr);
int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr, int);
-int ospf_area_export_list_set (struct ospf_area *, char *);
-int ospf_area_export_list_unset (struct ospf_area *);
-int ospf_area_import_list_set (struct ospf_area *, char *);
-int ospf_area_import_list_unset (struct ospf_area *);
-int ospf_area_shortcut_set (struct ospf_area *, int);
-int ospf_area_shortcut_unset (struct ospf_area *);
+int ospf_area_export_list_set (struct ospf *, struct ospf_area *, char *);
+int ospf_area_export_list_unset (struct ospf *, struct ospf_area *);
+int ospf_area_import_list_set (struct ospf *, struct ospf_area *, char *);
+int ospf_area_import_list_unset (struct ospf *, struct ospf_area *);
+int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int);
+int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *);
int ospf_timers_spf_set (struct ospf *, u_int32_t, u_int32_t);
int ospf_timers_spf_unset (struct ospf *);
int ospf_timers_refresh_set (struct ospf *, int);
@@ -538,18 +537,18 @@ int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr, int);
int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr);
void ospf_prefix_list_update (struct prefix_list *);
void ospf_init ();
-void ospf_if_update ();
+void ospf_if_update (struct ospf *);
void ospf_ls_upd_queue_empty (struct ospf_interface *);
void ospf_terminate ();
-void ospf_nbr_nbma_if_update (struct ospf_interface *);
+void ospf_nbr_nbma_if_update (struct ospf *, struct ospf_interface *);
struct ospf_nbr_nbma *ospf_nbr_nbma_lookup (struct ospf *, struct in_addr);
-struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct in_addr *, int);
+struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *,
+ struct in_addr *, int);
int ospf_oi_count (struct interface *);
-struct ospf_area *ospf_area_new (struct in_addr);
-struct ospf_area *ospf_area_get (struct in_addr, int);
-void ospf_area_check_free (struct in_addr);
-struct ospf_area *ospf_area_lookup_by_area_id (struct in_addr);
+struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int);
+void ospf_area_check_free (struct ospf *, struct in_addr);
+struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *, struct in_addr);
void ospf_area_add_if (struct ospf_area *, struct ospf_interface *);
void ospf_area_del_if (struct ospf_area *, struct ospf_interface *);