summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_ia.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_ia.c')
-rw-r--r--ospfd/ospf_ia.c151
1 files changed, 75 insertions, 76 deletions
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 59f86669..32c8d86b 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -71,9 +71,8 @@ ospf_find_abr_route (struct route_table *rtrs,
}
void
-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)
+ospf_ia_network_route (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;
@@ -95,7 +94,7 @@ ospf_ia_network_route (struct ospf *ospf, struct route_table *rt,
zlog_info ("ospf_ia_network_route(): "
"Found a route to the same network");
/* Check the existing route. */
- if ((res = ospf_route_cmp (ospf, new_or, or)) < 0)
+ if ((res = ospf_route_cmp (new_or, or)) < 0)
{
/* New route is better, so replace old one. */
ospf_route_subst (rn1, new_or, abr_or);
@@ -128,19 +127,18 @@ ospf_ia_network_route (struct ospf *ospf, struct route_table *rt,
}
void
-ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs,
- struct prefix_ipv4 *p,
+ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
struct ospf_route *new_or, struct ospf_route *abr_or)
{
- struct ospf_route *or = NULL;
struct route_node *rn;
+ struct ospf_route *or = NULL;
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 (rtrs, (struct prefix *) p);
+ rn = route_node_get (rt,(struct prefix *) p);
if (rn->info == NULL)
/* This is a new route */
@@ -148,11 +146,11 @@ ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs,
else
{
struct ospf_area *or_area;
- or_area = ospf_area_lookup_by_area_id (ospf, new_or->u.std.area_id);
+ or_area = ospf_area_lookup_by_area_id (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 (rtrs, p, or_area);
+ or = ospf_find_asbr_route_through_area (rt, p, or_area);
}
if (or)
@@ -161,7 +159,7 @@ ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs,
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 (ospf, new_or, or)) < 0)
+ if ((ret = ospf_route_cmp (new_or, or)) < 0)
{
listnode_delete (rn->info, or);
ospf_route_free (or);
@@ -196,21 +194,28 @@ ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs,
}
+struct ia_args
+{
+ struct route_table *rt;
+ struct route_table *rtrs;
+ struct ospf_area *area;
+};
+
int
-process_summary_lsa (struct ospf_area *area, struct route_table *rt,
- struct route_table *rtrs, struct ospf_lsa *lsa)
+process_summary_lsa (struct ospf_lsa *l, void *v, int i)
{
- 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 (lsa == NULL)
+ if (l == NULL)
return 0;
- sl = (struct summary_lsa *) lsa->data;
+ args = (struct ia_args *) v;
+ sl = (struct summary_lsa *) l->data;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_summary_lsa(): LS ID: %s", inet_ntoa (sl->header.id));
@@ -220,10 +225,10 @@ process_summary_lsa (struct ospf_area *area, struct route_table *rt,
if (metric == OSPF_LS_INFINITY)
return 0;
- if (IS_LSA_MAXAGE (lsa))
+ if (IS_LSA_MAXAGE (l))
return 0;
- if (ospf_lsa_is_self_originated (area->ospf, lsa))
+ if (ospf_lsa_is_self_originated (l))
return 0;
p.family = AF_INET;
@@ -237,12 +242,12 @@ process_summary_lsa (struct ospf_area *area, struct route_table *rt,
apply_mask_ipv4 (&p);
if (sl->header.type == OSPF_SUMMARY_LSA &&
- (range = ospf_area_range_match_any (ospf, &p)) &&
+ (range = ospf_area_range_match_any (ospf_top, &p)) &&
ospf_area_range_active (range))
return 0;
- if (ospf->abr_type != OSPF_ABR_STAND &&
- area->external_routing != OSPF_AREA_DEFAULT &&
+ if (ospf_top->abr_type != OSPF_ABR_STAND &&
+ args->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 */
@@ -252,7 +257,7 @@ process_summary_lsa (struct ospf_area *area, struct route_table *rt,
abr.prefixlen = IPV4_MAX_BITLEN;
apply_mask_ipv4 (&abr);
- abr_or = ospf_find_abr_route (rtrs, &abr, area);
+ abr_or = ospf_find_abr_route (args->rtrs, &abr, args->area);
if (abr_or == NULL)
return 0;
@@ -264,35 +269,32 @@ process_summary_lsa (struct ospf_area *area, struct route_table *rt,
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 = area->area_id;
+ new_or->u.std.area_id = args->area->area_id;
#ifdef HAVE_NSSA
- new_or->u.std.external_routing = area->external_routing;
+ new_or->u.std.external_routing = args->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 (ospf, rt, &p, new_or, abr_or);
+ ospf_ia_network_route (args->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 (ospf, rtrs, &p, new_or, abr_or);
+ ospf_ia_router_route (args->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 ospf_lsa *lsa;
- struct route_node *rn;
-
- LSDB_LOOP (lsdb_rt, rn, lsa)
- process_summary_lsa (area, rt, rtrs, lsa);
+ struct ia_args args = {rt, rtrs, area};
+ foreach_lsa (lsdb_rt, &args, 0, process_summary_lsa);
}
int
@@ -303,8 +305,7 @@ ospf_area_is_transit (struct ospf_area *area)
}
void
-ospf_update_network_route (struct ospf *ospf,
- struct route_table *rt,
+ospf_update_network_route (struct route_table *rt,
struct route_table *rtrs,
struct summary_lsa *lsa,
struct prefix_ipv4 *p,
@@ -335,7 +336,7 @@ ospf_update_network_route (struct ospf *ospf,
if (! rn)
{
- if (ospf->abr_type != OSPF_ABR_SHORTCUT)
+ if (ospf_top->abr_type != OSPF_ABR_SHORTCUT)
return; /* Standard ABR can update only already installed
backbone paths */
if (IS_DEBUG_OSPF_EVENT)
@@ -374,7 +375,7 @@ ospf_update_network_route (struct ospf *ospf,
return;
}
- if (ospf->abr_type == OSPF_ABR_SHORTCUT)
+ if (ospf_top->abr_type == OSPF_ABR_SHORTCUT)
{
if (or->path_type == OSPF_PATH_INTRA_AREA &&
!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
@@ -419,7 +420,7 @@ ospf_update_network_route (struct ospf *ospf,
ospf_route_subst_nexthops (or, abr_or->path);
or->cost = cost;
- if ((ospf->abr_type == OSPF_ABR_SHORTCUT) &&
+ if ((ospf_top->abr_type == OSPF_ABR_SHORTCUT) &&
!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
{
or->path_type = OSPF_PATH_INTER_AREA;
@@ -436,8 +437,7 @@ ospf_update_network_route (struct ospf *ospf,
}
void
-ospf_update_router_route (struct ospf *ospf,
- struct route_table *rtrs,
+ospf_update_router_route (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 ospf *ospf,
/* First try to find a backbone path,
because standard ABR can update only BB-associated paths */
- if ((ospf->backbone == NULL) &&
- (ospf->abr_type != OSPF_ABR_SHORTCUT))
+ if ((ospf_top->backbone == NULL) &&
+ (ospf_top->abr_type != OSPF_ABR_SHORTCUT))
/* no BB area, not Shortcut ABR, exiting */
return;
- or = ospf_find_asbr_route_through_area (rtrs, p, ospf->backbone);
+ or = ospf_find_asbr_route_through_area (rtrs, p, ospf_top->backbone);
if (or == NULL)
{
- if (ospf->abr_type != OSPF_ABR_SHORTCUT)
+ if (ospf_top->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 ospf *ospf,
#endif /* HAVE_NSSA */
new_or->path_type = OSPF_PATH_INTER_AREA;
new_or->u.std.flags = ROUTER_LSA_EXTERNAL;
- ospf_ia_router_route (ospf, rtrs, p, new_or, abr_or);
+ ospf_ia_router_route (rtrs, p, new_or, abr_or);
return;
}
@@ -537,22 +537,22 @@ ospf_update_router_route (struct ospf *ospf,
}
int
-process_transit_summary_lsa (struct ospf_area *area, struct route_table *rt,
- struct route_table *rtrs, struct ospf_lsa *lsa)
+process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i)
{
- struct ospf *ospf = area->ospf;
struct summary_lsa *sl;
struct prefix_ipv4 p;
u_int32_t metric;
+ struct ia_args *args;
- if (lsa == NULL)
+ if (l == NULL)
return 0;
- sl = (struct summary_lsa *) lsa->data;
+ args = (struct ia_args *) v;
+ sl = (struct summary_lsa *) l->data;
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): LS ID: %s",
- inet_ntoa (lsa->data->id));
+ inet_ntoa (l->data->id));
metric = GET_METRIC (sl->metric);
if (metric == OSPF_LS_INFINITY)
@@ -562,14 +562,14 @@ process_transit_summary_lsa (struct ospf_area *area, struct route_table *rt,
return 0;
}
- if (IS_LSA_MAXAGE (lsa))
+ if (IS_LSA_MAXAGE (l))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): This LSA is too old");
return 0;
}
- if (ospf_lsa_is_self_originated (area->ospf, lsa))
+ if (ospf_lsa_is_self_originated (l))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): This LSA is mine, skip");
@@ -587,29 +587,28 @@ process_transit_summary_lsa (struct ospf_area *area, struct route_table *rt,
apply_mask_ipv4 (&p);
if (sl->header.type == OSPF_SUMMARY_LSA)
- ospf_update_network_route (ospf, rt, rtrs, sl, &p, area);
+ ospf_update_network_route (args->rt, args->rtrs, sl, &p, args->area);
else
- ospf_update_router_route (ospf, rtrs, sl, &p, area);
+ ospf_update_router_route (args->rtrs, sl, &p, args->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 ospf_lsa *lsa;
- struct route_node *rn;
+ struct ia_args args = {rt, rtrs, area};
- LSDB_LOOP (lsdb_rt, rn, lsa)
- process_transit_summary_lsa (area, rt, rtrs, lsa);
+ /* ospf_lsdb_iterator (lsdb, &args, 0, process_transit_summary_lsa); */
+ foreach_lsa (lsdb_rt, &args, 0, process_transit_summary_lsa);
}
void
-ospf_ia_routing (struct ospf *ospf,
- struct route_table *rt,
+ospf_ia_routing (struct route_table *rt,
struct route_table *rtrs)
{
struct ospf_area * area;
@@ -617,18 +616,18 @@ ospf_ia_routing (struct ospf *ospf,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():start");
- if (IS_OSPF_ABR (ospf))
+ if (OSPF_IS_ABR)
{
listnode node;
struct ospf_area *area;
- switch (ospf->abr_type)
+ switch (ospf_top->abr_type)
{
case OSPF_ABR_STAND:
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Standard ABR");
- if ((area = ospf->backbone))
+ if ((area = ospf_top->backbone))
{
listnode node;
@@ -640,9 +639,9 @@ ospf_ia_routing (struct ospf *ospf,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (node = listhead (ospf_top->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
+ if (area != ospf_top->backbone)
if (ospf_area_is_transit (area))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
@@ -654,10 +653,10 @@ ospf_ia_routing (struct ospf *ospf,
case OSPF_ABR_CISCO:
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Alternative Cisco/IBM ABR");
- area = ospf->backbone; /* Find the BB */
+ area = ospf_top->backbone; /* Find the BB */
/* If we have an active BB connection */
- if (area && ospf_act_bb_connection (ospf))
+ if (area && ospf_act_bb_connection ())
{
if (IS_DEBUG_OSPF_EVENT)
{
@@ -667,9 +666,9 @@ ospf_ia_routing (struct ospf *ospf,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (node = listhead (ospf_top->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
+ if (area != ospf_top->backbone)
if (ospf_area_is_transit (area))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
@@ -678,7 +677,7 @@ ospf_ia_routing (struct ospf *ospf,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing(): "
"Active BB connection not found");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (node = listhead (ospf_top->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
@@ -686,10 +685,10 @@ ospf_ia_routing (struct ospf *ospf,
case OSPF_ABR_SHORTCUT:
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Alternative Shortcut");
- area = ospf->backbone; /* Find the BB */
+ area = ospf_top->backbone; /* Find the BB */
/* If we have an active BB connection */
- if (area && ospf_act_bb_connection (ospf))
+ if (area && ospf_act_bb_connection ())
{
if (IS_DEBUG_OSPF_EVENT)
{
@@ -699,12 +698,12 @@ ospf_ia_routing (struct ospf *ospf,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (node = listhead (ospf_top->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
+ if (area != ospf_top->backbone)
if (ospf_area_is_transit (area) ||
((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
- ((ospf->backbone == NULL) ||
+ ((ospf_top->backbone == NULL) ||
((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
area->shortcut_capability))))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
@@ -720,7 +719,7 @@ ospf_ia_routing (struct ospf *ospf,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():not ABR, considering all areas");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (node = listhead (ospf_top->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}