summaryrefslogtreecommitdiff
path: root/ospfd/ospf_ase.c
diff options
context:
space:
mode:
authorpaul <paul>2005-04-07 07:30:20 +0000
committerpaul <paul>2005-04-07 07:30:20 +0000
commit1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch)
treef5b09d4781de9a9b08839fefb6530e64d2d2ec31 /ospfd/ospf_ase.c
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist, and some basic auditing of usage. * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES * HACKING: Add notes about deprecating interfaces and commands. * lib/linklist.h: Add usage comments. Rename getdata macro to listgetdata. Rename nextnode to listnextnode and fix its odd behaviour to be less dangerous. Make listgetdata macro assert node is not null, NULL list entries should be bug condition. ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use with for loop, Suggested by Jim Carlson of Sun. Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the "safety" of previous macro. LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to distinguish from the similarly named functions, and reflect their effect better. Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section with the old defines which were modified above, for backwards compatibility - guarded to prevent Quagga using it.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single scan of the area list, rather than scanning all areas first for INTER_ROUTER and then again for INTER_NETWORK. According to 16.2, the scan should be area specific anyway, and further ospf6d does not seem to implement 16.3 anyway.
Diffstat (limited to 'ospfd/ospf_ase.c')
-rw-r--r--ospfd/ospf_ase.c84
1 files changed, 38 insertions, 46 deletions
diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c
index c4f4dd3d..f9f79e3c 100644
--- a/ospfd/ospf_ase.c
+++ b/ospfd/ospf_ase.c
@@ -71,12 +71,11 @@ ospf_find_asbr_route (struct ospf *ospf,
/* First try to find intra-area non-bb paths. */
if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (or->cost < OSPF_LS_INFINITY)
- if (!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id) &&
- or->path_type == OSPF_PATH_INTRA_AREA)
- listnode_add (chosen, or);
+ for (ALL_LIST_ELEMENTS_RO ((struct list *) rn->info, node, or))
+ if (or->cost < OSPF_LS_INFINITY)
+ if (!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id) &&
+ or->path_type == OSPF_PATH_INTRA_AREA)
+ listnode_add (chosen, or);
/* If none is found -- look through all. */
if (listcount (chosen) == 0)
@@ -86,19 +85,18 @@ ospf_find_asbr_route (struct ospf *ospf,
}
/* Now find the route with least cost. */
- for (node = listhead (chosen); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (or->cost < OSPF_LS_INFINITY)
- {
- if (best == NULL)
- best = or;
- else if (best->cost > or->cost)
- best = or;
- else if (best->cost == or->cost &&
- IPV4_ADDR_CMP (&best->u.std.area_id,
- &or->u.std.area_id) < 0)
- best = or;
- }
+ for (ALL_LIST_ELEMENTS_RO (chosen, node, or))
+ if (or->cost < OSPF_LS_INFINITY)
+ {
+ if (best == NULL)
+ best = or;
+ else if (best->cost > or->cost)
+ best = or;
+ else if (best->cost == or->cost &&
+ IPV4_ADDR_CMP (&best->u.std.area_id,
+ &or->u.std.area_id) < 0)
+ best = or;
+ }
if (chosen != rn->info)
list_delete (chosen);
@@ -126,10 +124,9 @@ ospf_find_asbr_route_through_area (struct route_table *rtrs,
route_unlock_node (rn);
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
- return or;
+ for (ALL_LIST_ELEMENTS_RO ((struct list *) rn->info, node, or))
+ if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
+ return or;
}
return NULL;
@@ -141,10 +138,9 @@ ospf_ase_complete_direct_routes (struct ospf_route *ro, struct in_addr nexthop)
struct listnode *node;
struct ospf_path *op;
- for (node = listhead (ro->paths); node; nextnode (node))
- if ((op = getdata (node)) != NULL)
- if (op->nexthop.s_addr == 0)
- op->nexthop.s_addr = nexthop.s_addr;
+ for (ALL_LIST_ELEMENTS_RO (ro->paths, node, op))
+ if (op->nexthop.s_addr == 0)
+ op->nexthop.s_addr = nexthop.s_addr;
}
int
@@ -153,12 +149,11 @@ ospf_ase_forward_address_check (struct ospf *ospf, struct in_addr fwd_addr)
struct listnode *ifn;
struct ospf_interface *oi;
- for (ifn = listhead (ospf->oiflist); ifn; nextnode (ifn))
- if ((oi = getdata (ifn)) != NULL)
- if (if_is_operative (oi->ifp))
- if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
- if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &fwd_addr))
- return 0;
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ifn, oi))
+ if (if_is_operative (oi->ifp))
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &fwd_addr))
+ return 0;
return 1;
}
@@ -590,10 +585,10 @@ ospf_ase_route_match_same (struct route_table *rt, struct prefix *prefix,
/* Check each path. */
for (n1 = listhead (or->paths), n2 = listhead (newor->paths);
- n1 && n2; nextnode (n1), nextnode (n2))
+ n1 && n2; n1 = listnextnode (n1), n2 = listnextnode (n2))
{
- op = getdata (n1);
- newop = getdata (n2);
+ op = listgetdata (n1);
+ newop = listgetdata (n2);
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
return 0;
@@ -650,9 +645,8 @@ ospf_ase_calculate_timer (struct thread *t)
/* This version simple adds to the table all NSSA areas */
if (ospf->anyNSSA)
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_ase_calculate_timer(): looking at area %s",
inet_ntoa (area->area_id));
@@ -758,17 +752,16 @@ ospf_ase_external_lsas_finish (struct route_table *rt)
struct route_node *rn;
struct ospf_lsa *lsa;
struct list *lst;
- struct listnode *node;
+ struct listnode *node, *nnode;
for (rn = route_top (rt); rn; rn = route_next (rn))
if ((lst = rn->info) != NULL)
{
- for (node = listhead (lst); node; node = nextnode (node))
- if ((lsa = getdata (node)) != NULL)
- ospf_lsa_unlock (lsa);
+ for (ALL_LIST_ELEMENTS (lst, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_delete (lst);
}
-
+
route_table_finish (rt);
}
@@ -808,9 +801,8 @@ ospf_ase_incremental_update (struct ospf *ospf, struct ospf_lsa *lsa)
assert (rn && rn->info);
lsas = rn->info;
- for (node = listhead (lsas); node; nextnode (node))
- if ((lsa = getdata (node)) != NULL)
- ospf_ase_calculate_route (ospf, lsa);
+ for (ALL_LIST_ELEMENTS_RO (lsas, node, lsa))
+ ospf_ase_calculate_route (ospf, lsa);
/* prepare temporary old routing table for compare */
tmp_old = route_table_init ();