summaryrefslogtreecommitdiff
path: root/ospfd/ospf_ia.c
diff options
context:
space:
mode:
authorpaul <paul>2003-08-10 02:51:22 +0000
committerpaul <paul>2003-08-10 02:51:22 +0000
commit96735eeafe4713b60700915dd2fb6dcbd0f09c8f (patch)
tree49b7f583956e3d7ad91dcfa006d18e20f57efe15 /ospfd/ospf_ia.c
parent286e1e71538440ed0bef4576aded1745191490d3 (diff)
2003-08-10 amir <amir@datacore.ch>
* Add missing 'i' to getopts, short form of --pid_file. see http://bugzilla.quagga.net/show_bug.cgi?id=25
Diffstat (limited to 'ospfd/ospf_ia.c')
-rw-r--r--ospfd/ospf_ia.c165
1 files changed, 83 insertions, 82 deletions
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 32c8d86b..e4c14686 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);
@@ -103,7 +104,7 @@ ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
{
/* New and old route are equal, so next hops can be added. */
route_lock_node (rn1);
- ospf_route_copy_nexthops (or, abr_or->path);
+ ospf_route_copy_nexthops (or, abr_or->paths);
route_unlock_node (rn1);
/* new route can be deleted, because existing route has been updated. */
@@ -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);
@@ -171,7 +173,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_router_route(): merging the new route");
- ospf_route_copy_nexthops (or, abr_or->path);
+ ospf_route_copy_nexthops (or, abr_or->paths);
ospf_route_free (new_or);
return;
}
@@ -185,7 +187,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
}
}
- ospf_route_copy_nexthops (new_or, abr_or->path);
+ ospf_route_copy_nexthops (new_or, abr_or->paths);
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_router_route(): adding the new route");
@@ -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))
@@ -409,7 +408,7 @@ ospf_update_network_route (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_update_network_route(): "
"new route is same distance, adding nexthops");
- ospf_route_copy_nexthops (or, abr_or->path);
+ ospf_route_copy_nexthops (or, abr_or->paths);
}
if (or->cost > cost)
@@ -417,10 +416,10 @@ ospf_update_network_route (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_update_network_route(): "
"new route is better, overriding nexthops");
- ospf_route_subst_nexthops (or, abr_or->path);
+ ospf_route_subst_nexthops (or, abr_or->paths);
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;
}
@@ -523,11 +523,11 @@ ospf_update_router_route (struct route_table *rtrs,
return;
else if (or->cost == cost)
- ospf_route_copy_nexthops (or, abr_or->path);
+ ospf_route_copy_nexthops (or, abr_or->paths);
else if (or->cost > cost)
{
- ospf_route_subst_nexthops (or, abr_or->path);
+ ospf_route_subst_nexthops (or, abr_or->paths);
or->cost = cost;
/* Even if the ABR runs in Shortcut mode, we can't change
@@ -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;
@@ -616,18 +617,18 @@ ospf_ia_routing (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():start");
- if (OSPF_IS_ABR)
+ if (IS_OSPF_ABR (ospf))
{
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);
}