summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_flood.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 /ospf6d/ospf6_flood.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 'ospf6d/ospf6_flood.c')
-rw-r--r--ospf6d/ospf6_flood.c60
1 files changed, 20 insertions, 40 deletions
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index 9971ef1c..39b7c1f3 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -245,7 +245,7 @@ void
ospf6_flood_interface (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
struct ospf6_lsa *req;
int retrans_added = 0;
@@ -259,10 +259,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
}
/* (1) For each neighbor */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
-
if (is_debug)
zlog_debug ("To neighbor %s", on->name);
@@ -380,9 +378,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
else
{
/* reschedule retransmissions to all neighbors */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->thread_send_lsupdate);
on->thread_send_lsupdate =
thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
@@ -394,13 +391,11 @@ void
ospf6_flood_area (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6_area *oa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = OSPF6_INTERFACE (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL &&
oi != OSPF6_INTERFACE (lsa->lsdb->data))
continue;
@@ -419,13 +414,11 @@ void
ospf6_flood_process (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6 *process)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (node = listhead (process->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA &&
oa != OSPF6_AREA (lsa->lsdb->data))
continue;
@@ -450,13 +443,12 @@ ospf6_flood (struct ospf6_neighbor *from, struct ospf6_lsa *lsa)
void
ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
struct ospf6_lsa *rem;
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = OSPF6_NEIGHBOR (getdata (node));
rem = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
lsa->header->adv_router, on->retrans_list);
if (rem && ! ospf6_lsa_compare (rem, lsa))
@@ -474,13 +466,11 @@ ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi)
void
ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = OSPF6_INTERFACE (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL &&
oi != OSPF6_INTERFACE (lsa->lsdb->data))
continue;
@@ -498,13 +488,11 @@ ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa)
void
ospf6_flood_clear_process (struct ospf6_lsa *lsa, struct ospf6 *process)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (node = listhead (process->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA &&
oa != OSPF6_AREA (lsa->lsdb->data))
continue;
@@ -725,21 +713,13 @@ ospf6_is_maxage_lsa_drop (struct ospf6_lsa *lsa, struct ospf6_neighbor *from)
return 0;
process = from->ospf6_if->area->ospf6;
- for (i = listhead (process->area_list); i; nextnode (i))
- {
- oa = OSPF6_AREA (getdata (i));
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = OSPF6_INTERFACE (getdata (j));
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = OSPF6_NEIGHBOR (getdata (k));
- if (on->state == OSPF6_NEIGHBOR_EXCHANGE ||
- on->state == OSPF6_NEIGHBOR_LOADING)
- count++;
- }
- }
- }
+
+ for (ALL_LIST_ELEMENTS_RO (process->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ if (on->state == OSPF6_NEIGHBOR_EXCHANGE ||
+ on->state == OSPF6_NEIGHBOR_LOADING)
+ count++;
if (count == 0)
return 1;