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.
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 416b3e7..90ed392 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -174,10 +174,11 @@
ospf_area_range_match_any (struct ospf *ospf, struct prefix_ipv4 *p)
{
struct ospf_area_range *range;
+ struct ospf_area *area;
struct listnode *node;
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((range = ospf_area_range_match (node->data, p)))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if ((range = ospf_area_range_match (area, p)))
return range;
return NULL;
@@ -407,9 +408,9 @@
ospf_abr_nssa_check_status (struct ospf *ospf)
{
struct ospf_area *area;
- struct listnode *lnode;
+ struct listnode *lnode, *nnode;
- LIST_LOOP (ospf->areas, area, lnode)
+ for (ALL_LIST_ELEMENTS (ospf->areas, lnode, nnode, area))
{
if (area->external_routing != OSPF_AREA_NSSA)
@@ -477,7 +478,7 @@
ospf_check_abr_status (struct ospf *ospf)
{
struct ospf_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
int bb_configured = 0;
int bb_act_attached = 0;
int areas_configured = 0;
@@ -487,10 +488,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_check_abr_status(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- area = getdata (node);
-
if (listcount (area->oiflist))
{
areas_configured++;
@@ -774,10 +773,10 @@
ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
struct ospf_area *area)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_path *path;
- LIST_LOOP (or->paths, path, node)
+ for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path))
{
struct ospf_interface *oi = path->oi;
@@ -851,10 +850,8 @@
or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
assert (or_area);
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_network(): looking at area %s",
inet_ntoa (area->area_id));
@@ -958,10 +955,8 @@
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_process_nssa_translates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (! area->NSSATranslatorState)
continue; /* skip if not translator */
@@ -1148,10 +1143,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_rtr(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_rtr(): looking at area %s",
inet_ntoa (area->area_id));
@@ -1205,7 +1198,7 @@
for (rn = route_top (rt); rn; rn = route_next (rn))
{
- struct listnode *node;
+ struct listnode *node, *nnode;
char flag = 0;
struct ospf_route *best = NULL;
@@ -1218,12 +1211,8 @@
zlog_debug ("ospf_abr_process_router_rt(): this is a route to %s",
inet_ntoa (rn->p.u.prefix4));
- for (node = listhead (l); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (l, node, nnode, or))
{
- or = getdata (node);
- if (or == NULL)
- continue;
-
if (!ospf_area_lookup_by_area_id (ospf, or->u.std.area_id))
{
if (IS_DEBUG_OSPF_EVENT)
@@ -1334,9 +1323,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_unapprove_summaries(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_unapprove_summaries(): "
"considering area %s",
@@ -1372,14 +1360,13 @@
struct listnode *node;
struct route_node *rn;
struct ospf_area_range *range;
+ struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_prepare_aggregates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = getdata (node);
-
for (rn = route_top (area->ranges); rn; rn = route_next (rn))
if ((range = rn->info) != NULL)
{
@@ -1404,10 +1391,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_aggregates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_aggregates(): looking at area %s",
inet_ntoa (area->area_id));
@@ -1444,9 +1429,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_aggregates(): active range");
- for (n = listhead (ospf->areas); n; nextnode (n))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, n, ar))
{
- ar = getdata (n);
if (ar == area)
continue;
@@ -1488,10 +1472,8 @@
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_send_nssa_aggregates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (! area->NSSATranslatorState)
continue;
@@ -1559,9 +1541,8 @@
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_announce_stub_defaults(): Start");
- 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_abr_announce_nssa_defaults(): looking at area %s",
inet_ntoa (area->area_id));
@@ -1601,9 +1582,8 @@
p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
p.prefixlen = 0;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_stub_defaults(): looking at area %s",
inet_ntoa (area->area_id));
@@ -1675,10 +1655,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_remove_unapproved_summaries(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_remove_unapproved_summaries(): "
"looking at area %s", inet_ntoa (area->area_id));
@@ -1701,23 +1679,22 @@
void
ospf_abr_manage_discard_routes (struct ospf *ospf)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct route_node *rn;
struct ospf_area *area;
struct ospf_area_range *range;
- 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->new_table, area,
- (struct prefix_ipv4 *) &rn->p);
- else
- ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
- }
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ 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->new_table, area,
+ (struct prefix_ipv4 *) &rn->p);
+ else
+ ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
+ }
}
/* This is the function taking care about ABR NSSA, i.e. NSSA
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 89af2a3..59233c7 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -83,15 +83,14 @@
struct ospf_interface *
ospf_apiserver_if_lookup_by_addr (struct in_addr address)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf *ospf;
if (!(ospf = ospf_lookup ()))
return NULL;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4))
return oi;
@@ -102,14 +101,14 @@
struct ospf_interface *
ospf_apiserver_if_lookup_by_ifp (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf *ospf;
if (!(ospf = ospf_lookup ()));
return NULL;
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
if (oi->ifp == ifp)
return oi;
@@ -190,7 +189,7 @@
* Free all client instances. ospf_apiserver_free removes the node
* from the list, so we examine the head of the list anew each time.
*/
- while ( (apiserv = getdata (listhead (apiserver_list))) != NULL)
+ while ( (apiserv = listgetdata (listhead (apiserver_list))) != NULL)
ospf_apiserver_free (apiserv);
/* Free client list itself */
@@ -208,20 +207,14 @@
struct ospf_apiserver *apiserv, *found = NULL;
/* XXX: this approaches O(n**2) */
- for (n1 = listhead (apiserver_list); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS_RO (apiserver_list, n1, apiserv))
{
- apiserv = (struct ospf_apiserver *) getdata (n1);
-
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
- {
- r = (struct registered_opaque_type *) getdata (n2);
-
- if (r->lsa_type == lsa_type && r->opaque_type == opaque_type)
- {
- found = apiserv;
- goto out;
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (apiserv->opaque_types, n2, r))
+ if (r->lsa_type == lsa_type && r->opaque_type == opaque_type)
+ {
+ found = apiserv;
+ goto out;
+ }
}
out:
return found;
@@ -373,8 +366,7 @@
while ((node = listhead (apiserv->opaque_types)) != NULL)
{
-
- struct registered_opaque_type *regtype = node->data;
+ struct registered_opaque_type *regtype = listgetdata(node);
ospf_apiserver_unregister_opaque_type (apiserv, regtype->lsa_type,
regtype->opaque_type);
@@ -964,15 +956,11 @@
ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type)
{
- struct listnode *n1, *n1_next;
+ struct listnode *node, *nnode;
struct registered_opaque_type *regtype;
- for (n1 = listhead (apiserv->opaque_types); n1; n1 = n1_next)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node, nnode, regtype))
{
- n1_next = n1->next;
-
- regtype = (struct registered_opaque_type *) getdata(n1);
-
/* Check if we really registered this opaque type */
if (regtype->lsa_type == lsa_type &&
regtype->opaque_type == opaque_type)
@@ -1008,11 +996,11 @@
apiserver_is_opaque_type_registered (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct registered_opaque_type *regtype;
/* XXX: how many types are there? if few, why not just a bitmap? */
- LIST_LOOP (apiserv->opaque_types, regtype, node)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node, nnode, regtype))
{
/* Check if we really registered this opaque type */
if (regtype->lsa_type == lsa_type &&
@@ -1070,15 +1058,15 @@
void
ospf_apiserver_notify_ready_type9 (struct ospf_apiserver *apiserv)
{
- struct listnode *node;
- struct listnode *n2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct ospf *ospf;
struct ospf_interface *oi;
struct registered_opaque_type *r;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
/* Check if this interface is indeed ready for type 9 */
if (!ospf_apiserver_is_ready_type9 (oi))
@@ -1086,7 +1074,7 @@
/* Check for registered opaque type 9 types */
/* XXX: loop-de-loop - optimise me */
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
struct msg *msg;
@@ -1121,14 +1109,14 @@
void
ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv)
{
- struct listnode *node;
- struct listnode *n2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct ospf *ospf;
struct ospf_area *area;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
struct registered_opaque_type *r;
@@ -1139,7 +1127,7 @@
/* Check for registered opaque type 10 types */
/* XXX: loop in loop - optimise me */
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
struct msg *msg;
@@ -1172,7 +1160,7 @@
void
ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf *ospf;
struct registered_opaque_type *r;
@@ -1183,7 +1171,7 @@
goto out;
/* Check for registered opaque type 11 types */
- LIST_LOOP (apiserv->opaque_types, r, node)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node, nnode, r))
{
struct msg *msg;
struct in_addr noarea_id = { 0L };
@@ -1350,16 +1338,15 @@
ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
struct msg *msg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
u_int32_t seqnum;
int rc = 0;
struct msg_sync_lsdb *smsg;
- struct param_t
+ struct ospf_apiserver_param_t
{
struct ospf_apiserver *apiserv;
struct lsa_filter_type *filter;
- }
- param;
+ } param;
u_int16_t mask;
struct route_node *rn;
struct ospf_lsa *lsa;
@@ -1381,7 +1368,7 @@
mask = ntohs (smsg->filter.typemask);
/* Iterate over all areas. */
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
int i;
u_int32_t *area_id = NULL;
@@ -1563,10 +1550,10 @@
/* Type 10 opaque LSA can be originated if there is at least one
interface belonging to the area that has an active opaque-capable
neighbor. */
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
- LIST_LOOP (area->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
/* Is there an active neighbor attached to this interface? */
if (ospf_apiserver_is_ready_type9 (oi))
return 1;
@@ -1580,10 +1567,10 @@
{
/* Type 11 opaque LSA can be originated if there is at least one interface
that has an active opaque-capable neighbor. */
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
/* Is there an active neighbor attached to this interface? */
if (ospf_apiserver_is_ready_type9 (oi))
return 1;
@@ -2050,7 +2037,7 @@
u_char lsa_type;
u_char opaque_type;
} param;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf * ospf;
struct ospf_area *area;
@@ -2068,12 +2055,12 @@
struct ospf_lsa *lsa;
case OSPF_OPAQUE_LINK_LSA:
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
break;
case OSPF_OPAQUE_AREA_LSA:
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
break;
@@ -2253,11 +2240,11 @@
void
ospf_apiserver_clients_notify_all (struct msg *msg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_apiserver *apiserv;
/* Send message to all clients */
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
ospf_apiserver_send_msg (apiserv, msg);
}
@@ -2266,7 +2253,7 @@
void
ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct msg *msg;
struct ospf_apiserver *apiserv;
@@ -2283,12 +2270,12 @@
return;
}
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
- struct listnode *n2;
+ struct listnode *node2, *nnode2;
struct registered_opaque_type *r;
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
if (r->lsa_type == OSPF_OPAQUE_LINK_LSA)
{
@@ -2319,7 +2306,7 @@
void
ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct msg *msg;
struct ospf_apiserver *apiserv;
@@ -2331,12 +2318,12 @@
return;
}
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
- struct listnode *n2;
+ struct listnode *node2, *nnode2;
struct registered_opaque_type *r;
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
if (r->lsa_type == OSPF_OPAQUE_AREA_LSA)
{
@@ -2367,7 +2354,7 @@
void
ospf_apiserver_clients_notify_ready_type11 (struct ospf *top)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct msg *msg;
struct in_addr id_null = { 0L };
struct ospf_apiserver *apiserv;
@@ -2380,12 +2367,12 @@
return;
}
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
- struct listnode *n2;
+ struct listnode *node2, *nnode2;
struct registered_opaque_type *r;
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
if (r->lsa_type == OSPF_OPAQUE_AS_LSA)
{
@@ -2499,7 +2486,7 @@
apiserver_clients_lsa_change_notify (u_char msgtype, struct ospf_lsa *lsa)
{
struct msg *msg;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_apiserver *apiserv;
/* Default area for AS-External and Opaque11 LSAs */
@@ -2530,7 +2517,7 @@
}
/* Now send message to all clients with a matching filter */
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
struct lsa_filter_type *filter;
u_int16_t mask;
diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c
index c4f4dd3..f9f79e3 100644
--- a/ospfd/ospf_ase.c
+++ b/ospfd/ospf_ase.c
@@ -71,12 +71,11 @@
/* 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 @@
}
/* 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 @@
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 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
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 @@
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 ();
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index 586c25f..06e0f1c 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -150,34 +150,33 @@
/* Look through all interfaces, not just area, since interface
could be moved from one area to another. */
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
/* These are sanity check. */
- if ((oi = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &new->data->id))
- {
- if (oi->area != area ||
- oi->type != OSPF_IFTYPE_BROADCAST ||
- !IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)))
- {
- ospf_schedule_lsa_flush_area (area, new);
- return;
- }
-
+ if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &new->data->id))
+ {
+ if (oi->area != area ||
+ oi->type != OSPF_IFTYPE_BROADCAST ||
+ !IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)))
+ {
+ ospf_schedule_lsa_flush_area (area, new);
+ return;
+ }
+
#ifdef HAVE_OPAQUE_LSA
- if (new->data->type == OSPF_OPAQUE_LINK_LSA)
- {
- ospf_opaque_lsa_refresh (new);
- return;
- }
+ if (new->data->type == OSPF_OPAQUE_LINK_LSA)
+ {
+ ospf_opaque_lsa_refresh (new);
+ return;
+ }
#endif /* HAVE_OPAQUE_LSA */
- ospf_lsa_unlock (oi->network_lsa_self);
- oi->network_lsa_self = ospf_lsa_lock (new);
-
- /* Schedule network-LSA origination. */
- ospf_network_lsa_timer_add (oi);
- return;
- }
+ ospf_lsa_unlock (oi->network_lsa_self);
+ oi->network_lsa_self = ospf_lsa_lock (new);
+
+ /* Schedule network-LSA origination. */
+ ospf_network_lsa_timer_add (oi);
+ return;
+ }
break;
case OSPF_SUMMARY_LSA:
case OSPF_ASBR_SUMMARY_LSA:
@@ -569,17 +568,16 @@
ospf_flood_through_area (struct ospf_area *area,
struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
int lsa_ack_flag = 0;
/* All other types are specific to a single area (Area A). The
eligible interfaces are all those interfaces attaching to the
Area A. If Area A is the backbone, this includes all the virtual
links. */
- for (node = listhead (area->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
{
- struct ospf_interface *oi = getdata (node);
-
if (area->area_id.s_addr != OSPF_AREA_BACKBONE &&
oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
@@ -609,6 +607,7 @@
struct ospf_lsa *lsa)
{
struct listnode *node;
+ struct ospf_area *area;
int lsa_ack_flag;
lsa_ack_flag = 0;
@@ -628,11 +627,11 @@
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("Flood/AS: NSSA TRANSLATED LSA");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
int continue_flag = 0;
- struct ospf_area *area = getdata (node);
struct listnode *if_node;
+ struct ospf_interface *oi;
switch (area->external_routing)
{
@@ -671,10 +670,8 @@
/* send to every interface in this area */
- for (if_node = listhead (area->oiflist); if_node; nextnode (if_node))
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, if_node, oi))
{
- struct ospf_interface *oi = getdata (if_node);
-
/* Skip virtual links */
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (ospf_flood_through_interface (oi, inbr, lsa)) /* lsa */
@@ -965,19 +962,21 @@
ospf_ls_retransmit_delete_nbr_area (struct ospf_area *area,
struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
- for (node = listhead (area->oiflist); node; nextnode (node))
- ospf_ls_retransmit_delete_nbr_if (getdata (node), lsa);
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
+ ospf_ls_retransmit_delete_nbr_if (oi, lsa);
}
void
ospf_ls_retransmit_delete_nbr_as (struct ospf *ospf, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- ospf_ls_retransmit_delete_nbr_if (getdata (node), lsa);
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
+ ospf_ls_retransmit_delete_nbr_if (oi, lsa);
}
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 5bdcfba..87613bf 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -62,10 +62,10 @@
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) && (or->u.std.flags & ROUTER_LSA_BORDER))
- 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)
+ && (or->u.std.flags & ROUTER_LSA_BORDER))
+ return or;
return NULL;
}
@@ -637,11 +637,10 @@
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
- if (ospf_area_is_transit (area))
- OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (area != ospf->backbone)
+ if (ospf_area_is_transit (area))
+ OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
else
if (IS_DEBUG_OSPF_EVENT)
@@ -664,20 +663,18 @@
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
- if (ospf_area_is_transit (area))
- OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (area != ospf->backbone)
+ if (ospf_area_is_transit (area))
+ OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
else
{ /* No active BB connection--consider all areas */
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_ia_routing(): "
"Active BB connection not found");
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
break;
case OSPF_ABR_SHORTCUT:
@@ -696,15 +693,14 @@
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
- if (ospf_area_is_transit (area) ||
- ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
- ((ospf->backbone == NULL) ||
- ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
- area->shortcut_capability))))
- OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (area != ospf->backbone)
+ if (ospf_area_is_transit (area) ||
+ ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
+ ((ospf->backbone == NULL) ||
+ ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
+ area->shortcut_capability))))
+ OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
break;
default:
break;
@@ -717,8 +713,7 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_ia_routing():not ABR, considering all areas");
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
}
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 027dfb9..f8490f5 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -258,16 +258,15 @@
ospf_if_cleanup (struct ospf_interface *oi)
{
struct route_node *rn;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_neighbor *nbr;
+ struct ospf_nbr_nbma *nbr_nbma;
+ struct ospf_lsa *lsa;
/* oi->nbrs and oi->nbr_nbma should be deletete on InterafceDown event */
/* delete all static neighbors attached to this interface */
- for (node = listhead (oi->nbr_nbma); node; )
+ for (ALL_LIST_ELEMENTS (oi->nbr_nbma, node, nnode, nbr_nbma))
{
- struct ospf_nbr_nbma *nbr_nbma = getdata (node);
- nextnode (node);
-
OSPF_POLL_TIMER_OFF (nbr_nbma->t_poll);
if (nbr_nbma->nbr)
@@ -288,8 +287,8 @@
OSPF_NSM_EVENT_EXECUTE (nbr, NSM_KillNbr);
/* Cleanup Link State Acknowlegdment list. */
- for (node = listhead (oi->ls_ack); node; nextnode (node))
- ospf_lsa_unlock (node->data);
+ for (ALL_LIST_ELEMENTS (oi->ls_ack, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_delete_all_node (oi->ls_ack);
oi->crypt_seqnum = 0;
@@ -362,7 +361,7 @@
struct ospf_interface *
ospf_if_is_configured (struct ospf *ospf, struct in_addr *address)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct prefix_ipv4 addr;
@@ -370,8 +369,8 @@
addr.prefix = *address;
addr.prefixlen = IPV4_MAX_PREFIXLEN;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (oi->type == OSPF_IFTYPE_POINTOPOINT)
{
@@ -414,11 +413,10 @@
ospf = ospf_lookup ();
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- if (((oi = getdata (node)) != NULL) && (oi == oic))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi == oic)
return oi;
- }
+
return NULL;
}
@@ -429,8 +427,8 @@
struct listnode *node;
struct ospf_interface *oi;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (ifp && oi->ifp != ifp)
continue;
@@ -450,9 +448,9 @@
struct prefix ptmp;
/* Check each Interface. */
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if ((oi->type == OSPF_IFTYPE_POINTOPOINT) &&
CONNECTED_DEST_HOST(oi->connected))
@@ -485,10 +483,8 @@
match = NULL;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- oi = getdata (node);
-
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
@@ -944,11 +940,10 @@
struct ospf_vl_data *vl_data;
struct listnode *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))
- return vl_data;
+ for (ALL_LIST_ELEMENTS_RO (area->ospf->vlinks, node, vl_data))
+ if (vl_data->vl_peer.s_addr == vl_peer.s_addr &&
+ IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
+ return vl_data;
return NULL;
}
@@ -1011,20 +1006,19 @@
changed = 1;
}
- for (node = listhead (v->nexthop); node; nextnode (node))
- if ((nh = getdata (node)) != NULL)
- {
- vl_data->out_oi = (struct ospf_interface *) nh->oi;
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nh))
+ {
+ vl_data->out_oi = (struct ospf_interface *) nh->oi;
+
+ if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
+ &vl_data->out_oi->address->u.prefix4))
+ changed = 1;
- if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
- &vl_data->out_oi->address->u.prefix4))
- changed = 1;
-
- voi->address->u.prefix4 = vl_data->out_oi->address->u.prefix4;
- voi->address->prefixlen = vl_data->out_oi->address->prefixlen;
+ voi->address->u.prefix4 = vl_data->out_oi->address->u.prefix4;
+ voi->address->prefixlen = vl_data->out_oi->address->prefixlen;
- break; /* We take the first interface. */
- }
+ break; /* We take the first interface. */
+ }
rl = (struct router_lsa *)v->lsa;
@@ -1093,11 +1087,8 @@
zlog_debug ("ospf_vl_up_check(): Area is %s", inet_ntoa (area->area_id));
}
- for (node = listhead (ospf->vlinks); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
- if ((vl_data = getdata (node)) == NULL)
- continue;
-
if (IS_DEBUG_OSPF_EVENT)
{
zlog_debug ("ospf_vl_up_check(): considering VL, name: %s",
@@ -1144,21 +1135,19 @@
struct listnode *node;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
- if ((vl_data = getdata (node)) != NULL)
- UNSET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED);
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
+ UNSET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED);
}
void
ospf_vl_shut_unapproved (struct ospf *ospf)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_vl_data *vl_data;
- 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);
+ for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
+ if (!CHECK_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED))
+ ospf_vl_shutdown (vl_data);
}
int
@@ -1181,10 +1170,9 @@
struct ospf_vl_data *vl_data;
int c = 0;
- 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++;
+ for (ALL_LIST_ELEMENTS_RO (area->ospf->vlinks, node, vl_data))
+ if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
+ c++;
return c;
}
@@ -1213,12 +1201,9 @@
struct listnode *node;
struct crypt_key *ck;
- for (node = listhead (auth_crypt); node; nextnode (node))
- {
- ck = getdata (node);
- if (ck->key_id == key_id)
- return ck;
- }
+ for (ALL_LIST_ELEMENTS_RO (auth_crypt, node, ck))
+ if (ck->key_id == key_id)
+ return ck;
return NULL;
}
@@ -1226,12 +1211,11 @@
int
ospf_crypt_key_delete (struct list *auth_crypt, u_char key_id)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct crypt_key *ck;
- for (node = listhead (auth_crypt); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (auth_crypt, node, nnode, ck))
{
- ck = getdata (node);
if (ck->key_id == key_id)
{
listnode_delete (auth_crypt, ck);
diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c
index dd0f066..5d498d7 100644
--- a/ospfd/ospf_ism.c
+++ b/ospfd/ospf_ism.c
@@ -53,10 +53,8 @@
/* Choose highest router priority.
In case of tie, choose highest Router ID. */
- for (node = listhead (routers); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (routers, node, nbr))
{
- nbr = getdata (node);
-
if (max == NULL)
max = nbr;
else
@@ -82,10 +80,8 @@
dr_list = list_new ();
/* Add neighbors to the list. */
- for (node = listhead (el_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (el_list, node, nbr))
{
- nbr = getdata (node);
-
/* neighbor declared to be DR. */
if (NBR_IS_DR (nbr))
listnode_add (dr_list, nbr);
@@ -126,10 +122,8 @@
no_dr_list = list_new ();
/* Add neighbors to the list. */
- for (node = listhead (el_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (el_list, node, nbr))
{
- nbr = getdata (node);
-
/* neighbor declared to be DR. */
if (NBR_IS_DR (nbr))
continue;
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 203c4a5..e02d457 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -656,11 +656,11 @@
router_lsa_link_set (struct stream *s, struct ospf_area *area)
{
struct listnode *node;
+ struct ospf_interface *oi;
int links = 0;
- for (node = listhead (area->oiflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
{
- struct ospf_interface *oi = node->data;
struct interface *ifp = oi->ifp;
/* Check interface is up, OSPF is enable. */
@@ -890,16 +890,16 @@
ospf_router_lsa_update_timer (struct thread *thread)
{
struct ospf *ospf = THREAD_ARG (thread);
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_area *area;
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("Timer[router-LSA Update]: (timer expire)");
ospf->t_router_lsa_update = NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = getdata (node);
struct ospf_lsa *lsa = area->router_lsa_self;
struct router_lsa *rl;
const char *area_str;
@@ -1396,7 +1396,8 @@
{
struct in_addr fwd;
struct prefix nh;
- struct listnode *n1;
+ struct listnode *node;
+ struct ospf_interface *oi;
fwd.s_addr = 0;
@@ -1408,15 +1409,11 @@
nh.u.prefix4 = nexthop;
nh.prefixlen = IPV4_MAX_BITLEN;
- for (n1 = listhead (ospf->oiflist); n1; nextnode (n1))
- {
- struct ospf_interface *oi = getdata (n1);
-
- if (if_is_operative (oi->ifp))
- if (oi->address->family == AF_INET)
- if (prefix_match (oi->address, &nh))
- return nexthop;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (if_is_operative (oi->ifp))
+ if (oi->address->family == AF_INET)
+ if (prefix_match (oi->address, &nh))
+ return nexthop;
return fwd;
}
@@ -1444,15 +1441,14 @@
{
struct in_addr fwd;
struct in_addr best_default;
- struct listnode *n1;
+ struct listnode *node;
+ struct ospf_interface *oi;
fwd.s_addr = 0;
best_default.s_addr = 0;
- for (n1 = listhead (area->ospf->oiflist); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS_RO (area->ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (n1);
-
if (if_is_operative (oi->ifp))
if (oi->area->external_routing == OSPF_AREA_NSSA)
if (oi->address && oi->address->family == AF_INET)
@@ -1618,7 +1614,8 @@
{
struct ospf_lsa *new;
struct as_external_lsa *extlsa;
- struct listnode *node;
+ struct ospf_area *area;
+ struct listnode *node, *nnode;
/* LSA may be a Type-5 originated via translation of a Type-7 LSA
* which originated from an NSSA area. In which case it should not be
@@ -1642,10 +1639,8 @@
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) */
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = getdata (node);
-
/* Don't install Type-7 LSA's into nonNSSA area */
if (area->external_routing != OSPF_AREA_NSSA)
continue;
@@ -1863,12 +1858,12 @@
/* find the type-7 from which supplied type-5 was translated,
* ie find first type-7 with same LSA Id.
*/
- struct listnode *ln;
+ struct listnode *ln, *lnn;
struct route_node *rn;
struct ospf_lsa *lsa;
struct ospf_area *area;
- LIST_LOOP (ospf->areas, area, ln)
+ for (ALL_LIST_ELEMENTS (ospf->areas, ln, lnn, area))
{
if (area->external_routing != OSPF_AREA_NSSA
&& !type7)
@@ -2112,14 +2107,13 @@
void
ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa;
struct ospf_area *area;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- if (((area = getdata (node)) != NULL)
- && (area->external_routing == OSPF_AREA_NSSA))
+ if (area->external_routing == OSPF_AREA_NSSA)
{
if (!(lsa = ospf_lsa_lookup (area, OSPF_AS_NSSA_LSA, p->prefix,
ospf->router_id)))
@@ -2749,11 +2743,11 @@
int
ospf_check_nbr_status (struct ospf *ospf)
{
- struct listnode *node;
-
- for (node = listhead (ospf->oiflist); node; node = nextnode (node))
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
+
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
- struct ospf_interface *oi = getdata (node);
struct route_node *rn;
struct ospf_neighbor *nbr;
@@ -2805,8 +2799,8 @@
ospf_maxage_lsa_remover (struct thread *thread)
{
struct ospf *ospf = THREAD_ARG (thread);
- struct listnode *node;
- struct listnode *next;
+ struct ospf_lsa *lsa;
+ struct listnode *node, *nnode;
int reschedule = 0;
ospf->t_maxage = NULL;
@@ -2817,11 +2811,8 @@
reschedule = !ospf_check_nbr_status (ospf);
if (!reschedule)
- for (node = listhead (ospf->maxage_lsa); node; node = next)
+ for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
{
- struct ospf_lsa *lsa = getdata (node);
- next = node->next;
-
if (lsa->retransmit_counter > 0)
{
reschedule = 1;
@@ -2872,9 +2863,10 @@
ospf_lsa_maxage_exist (struct ospf *ospf, struct ospf_lsa *new)
{
struct listnode *node;
-
- for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
- if (((struct ospf_lsa *) node->data) == new)
+ struct ospf_lsa *lsa;
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
+ if (lsa == new)
return 1;
return 0;
@@ -2965,14 +2957,13 @@
struct ospf *ospf = THREAD_ARG (thread);
struct route_node *rn;
struct ospf_lsa *lsa;
- struct listnode *node;
+ struct ospf_area *area;
+ struct listnode *node, *nnode;
ospf->t_maxage_walker = NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = node->data;
-
LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
ospf_lsa_maxage_walker_remover (ospf, lsa);
LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
@@ -3292,18 +3283,16 @@
void
ospf_flush_self_originated_lsas_now (struct ospf *ospf)
{
- struct listnode *n1, *n2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
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 (ospf->areas); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- if ((area = getdata (n1)) == NULL)
- continue;
-
if ((lsa = area->router_lsa_self) != NULL)
{
if (IS_DEBUG_OSPF_EVENT)
@@ -3315,14 +3304,11 @@
OSPF_TIMER_OFF (area->t_router_lsa_self);
}
- for (n2 = listhead (area->oiflist); n2; nextnode (n2))
+ for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi))
{
- if ((oi = getdata (n2)) == NULL)
- continue;
-
if ((lsa = oi->network_lsa_self) != NULL
- && oi->state == ISM_DR
- && oi->full_nbrs > 0)
+ && oi->state == ISM_DR
+ && oi->full_nbrs > 0)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id));
@@ -3380,6 +3366,7 @@
ospf_lsa_is_self_originated (struct ospf *ospf, struct ospf_lsa *lsa)
{
struct listnode *node;
+ struct ospf_interface *oi;
/* This LSA is already checked. */
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED))
@@ -3399,10 +3386,8 @@
/* LSA is network-LSA. Compare Link ID with all interfaces. */
else if (lsa->data->type == OSPF_NETWORK_LSA)
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
-
/* Ignore virtual link. */
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (oi->address->family == AF_INET)
@@ -3662,8 +3647,9 @@
ospf_lsa_refresh_walker (struct thread *t)
{
struct list *refresh_list;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf *ospf = THREAD_ARG (t);
+ struct ospf_lsa *lsa;
int i;
struct list *lsa_to_refresh = list_new ();
@@ -3698,12 +3684,8 @@
if (refresh_list)
{
- for (node = listhead (refresh_list); node;)
+ for (ALL_LIST_ELEMENTS (refresh_list, node, nnode, lsa))
{
- struct listnode *next;
- struct ospf_lsa *lsa = getdata (node);
- next = node->next;
-
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): "
"refresh lsa %p (slot %d)",
@@ -3713,7 +3695,6 @@
ospf_lsa_unlock (lsa);
lsa->refresh_list = -1;
listnode_add (lsa_to_refresh, lsa);
- node = next;
}
list_free (refresh_list);
}
@@ -3723,8 +3704,8 @@
ospf, ospf->lsa_refresh_interval);
ospf->lsa_refresher_started = time (NULL);
- for (node = listhead (lsa_to_refresh); node; nextnode (node))
- ospf_lsa_refresh (ospf, getdata (node));
+ for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
+ ospf_lsa_refresh (ospf, lsa);
list_delete (lsa_to_refresh);
diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index 61366ed..35906ec 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -304,9 +304,9 @@
ospf_flush_self_originated_lsas_now (top);
/* Revert all neighbor status to ExStart. */
- for (node = listhead (top->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (top->oiflist, node, oi))
{
- if ((oi = getdata (node)) == NULL || (nbrs = oi->nbrs) == NULL)
+ if ((nbrs = oi->nbrs) == NULL)
continue;
for (rn = route_top (nbrs); rn; rn = route_next (rn))
@@ -355,11 +355,8 @@
struct ospf_nbr_nbma *nbr_nbma;
struct listnode *node;
- for (node = listhead (oi->nbr_nbma); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, node, nbr_nbma))
{
- nbr_nbma = getdata (node);
- assert (nbr_nbma);
-
if (IPV4_ADDR_SAME(&nbr_nbma->addr, &nbr->src))
{
nbr_nbma->nbr = nbr;
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 01a8e1c..d6b2f25 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -371,10 +371,10 @@
}
else
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->opaque_type == opaque_type)
{
zlog_warn ("ospf_register_opaque_functab: Duplicated entry?:"
@@ -418,14 +418,13 @@
ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type)
{
struct list *funclist;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
if ((funclist = ospf_get_opaque_funclist (lsa_type)) != NULL)
- for (node = listhead (funclist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
{
- if ((functab = getdata (node)) != NULL
- && functab->opaque_type == opaque_type)
+ if (functab->opaque_type == opaque_type)
{
/* Cleanup internal control information, if it still remains. */
if (functab->oipt != NULL)
@@ -455,7 +454,7 @@
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
if ((funclist = ospf_get_opaque_funclist (lsa->data->type)) != NULL)
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS_RO (funclist, node, functab))
if (functab->opaque_type == key)
return functab;
@@ -588,13 +587,11 @@
struct opaque_info_per_type *oipt = (struct opaque_info_per_type *) val;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Control information per opaque-id may still exist. */
- for (node = listhead (oipt->id_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oipt->id_list, node, nnode, oipi))
{
- if ((oipi = getdata (node)) == NULL)
- continue;
if ((lsa = oipi->lsa) == NULL)
continue;
if (IS_LSA_MAXAGE (lsa))
@@ -641,7 +638,7 @@
struct ospf_area *area;
struct ospf_interface *oi;
struct list *listtop = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_type *oipt = NULL;
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
@@ -674,7 +671,7 @@
}
if (listtop != NULL)
- LIST_LOOP (listtop, oipt, node)
+ for (ALL_LIST_ELEMENTS (listtop, node, nnode, oipt))
if (oipt->opaque_type == key)
return oipt;
@@ -720,11 +717,11 @@
lookup_opaque_info_by_id (struct opaque_info_per_type *oipt,
struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_id *oipi;
u_int32_t key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- LIST_LOOP (oipt->id_list, oipi, node)
+ for (ALL_LIST_ELEMENTS (oipt->id_list, node, nnode, oipi))
if (oipi->opaque_id == key)
return oipi;
@@ -827,11 +824,11 @@
static int
opaque_lsa_new_if_callback (struct list *funclist, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->new_if_hook != NULL)
if ((* functab->new_if_hook)(ifp) != 0)
goto out;
@@ -843,11 +840,11 @@
static int
opaque_lsa_del_if_callback (struct list *funclist, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->del_if_hook != NULL)
if ((* functab->del_if_hook)(ifp) != 0)
goto out;
@@ -860,10 +857,10 @@
opaque_lsa_ism_change_callback (struct list *funclist,
struct ospf_interface *oi, int old_status)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->ism_change_hook != NULL)
(* functab->ism_change_hook)(oi, old_status);
@@ -874,10 +871,10 @@
opaque_lsa_nsm_change_callback (struct list *funclist,
struct ospf_neighbor *nbr, int old_status)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->nsm_change_hook != NULL)
(* functab->nsm_change_hook)(nbr, old_status);
return;
@@ -887,10 +884,10 @@
opaque_lsa_config_write_router_callback (struct list *funclist,
struct vty *vty)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->config_write_router != NULL)
(* functab->config_write_router)(vty);
return;
@@ -900,10 +897,10 @@
opaque_lsa_config_write_if_callback (struct list *funclist,
struct vty *vty, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->config_write_if != NULL)
(* functab->config_write_if)(vty, ifp);
return;
@@ -912,10 +909,10 @@
static void
opaque_lsa_config_write_debug_callback (struct list *funclist, struct vty *vty)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->config_write_debug != NULL)
(* functab->config_write_debug)(vty);
return;
@@ -924,11 +921,11 @@
static int
opaque_lsa_originate_callback (struct list *funclist, void *lsa_type_dependent)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->lsa_originator != NULL)
if ((* functab->lsa_originator)(lsa_type_dependent) != 0)
goto out;
@@ -940,12 +937,12 @@
static int
new_lsa_callback (struct list *funclist, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->new_lsa_hook != NULL)
if ((* functab->new_lsa_hook)(lsa) != 0)
goto out;
@@ -957,12 +954,12 @@
static int
del_lsa_callback (struct list *funclist, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->del_lsa_hook != NULL)
if ((* functab->del_lsa_hook)(lsa) != 0)
goto out;
@@ -1291,7 +1288,7 @@
{
struct ospf *top;
struct ospf_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_type *oipt;
int delay = 0;
@@ -1381,7 +1378,7 @@
if (! list_isempty (ospf_opaque_type9_funclist)
&& ! list_isempty (oi->opaque_lsa_self))
{
- for (node = listhead (oi->opaque_lsa_self); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->opaque_lsa_self, node, nnode, oipt))
{
/*
* removed the test for
@@ -1389,9 +1386,8 @@
* because opaque cababilities ON -> OFF -> ON result in list_isempty (oipt->id_list)
* not being empty.
*/
- if ((oipt = getdata (node)) == NULL /* Something wrong? */
- || oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
+ if (oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
continue;
ospf_opaque_lsa_reoriginate_schedule ((void *) oi,
@@ -1402,7 +1398,7 @@
if (! list_isempty (ospf_opaque_type10_funclist)
&& ! list_isempty (area->opaque_lsa_self))
{
- for (node = listhead (area->opaque_lsa_self); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->opaque_lsa_self, node, nnode, oipt))
{
/*
* removed the test for
@@ -1410,9 +1406,8 @@
* because opaque cababilities ON -> OFF -> ON result in list_isempty (oipt->id_list)
* not being empty.
*/
- if ((oipt = getdata (node)) == NULL /* Something wrong? */
- || oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
+ if (oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
continue;
ospf_opaque_lsa_reoriginate_schedule ((void *) area,
@@ -1423,7 +1418,7 @@
if (! list_isempty (ospf_opaque_type11_funclist)
&& ! list_isempty (top->opaque_lsa_self))
{
- for (node = listhead (top->opaque_lsa_self); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (top->opaque_lsa_self, node, nnode, oipt))
{
/*
* removed the test for
@@ -1431,9 +1426,8 @@
* because opaque cababilities ON -> OFF -> ON result in list_isempty (oipt->id_list)
* not being empty.
*/
- if ((oipt = getdata (node)) == NULL /* Something wrong? */
- || oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
+ if (oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
continue;
ospf_opaque_lsa_reoriginate_schedule ((void *) top,
@@ -1504,7 +1498,7 @@
static void
ospf_opaque_lsa_reoriginate_resume (struct list *listtop, void *arg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab;
@@ -1515,7 +1509,7 @@
* Pickup oipt entries those which in SUSPEND status, and give
* them a chance to start re-origination now.
*/
- LIST_LOOP (listtop, oipt, node)
+ for (ALL_LIST_ELEMENTS (listtop, node, nnode, oipt))
{
if (oipt->status != PROC_SUSPEND)
continue;
@@ -1889,7 +1883,7 @@
{
struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
@@ -1914,7 +1908,7 @@
/* There must be at least one "opaque-capable, full-state" neighbor. */
n = 0;
- LIST_LOOP (area->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
{
if ((n = ospf_nbr_count_opaque_capable (oi)) > 0)
break;
@@ -2144,7 +2138,8 @@
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
- struct listnode *node1, *node2;
+ struct listnode *node1, *nnode1;
+ struct listnode *node2, *nnode2;
struct ospf_lsa *lsa;
if ((top = oi_to_top (nbr->oi)) == NULL)
@@ -2161,11 +2156,8 @@
* Obviously, the latter would trigger miserable situations that repeat
* installation and removal of unwanted LSAs indefinitely.
*/
- for (node1 = listhead (lsas); node1; nextnode (node1))
+ for (ALL_LIST_ELEMENTS (lsas, node1, nnode1, lsa))
{
- if ((lsa = getdata (node1)) == NULL)
- continue;
-
/* Filter out unwanted LSAs. */
if (! IS_OPAQUE_LSA (lsa->data->type))
continue;
@@ -2198,20 +2190,12 @@
break;
case OSPF_OPAQUE_AREA_LSA:
area = nbr->oi->area;
- for (node2 = listhead (area->oiflist); node2; nextnode (node2))
- {
- if ((oi = getdata (node2)) == NULL)
- continue;
- ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
- }
+ for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi))
+ ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
break;
case OSPF_OPAQUE_AS_LSA:
- for (node2 = listhead (top->oiflist); node2; nextnode (node2))
- {
- if ((oi = getdata (node2)) == NULL)
- continue;
- ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
- }
+ for (ALL_LIST_ELEMENTS (top->oiflist, node2, nnode2, oi))
+ ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
break;
default:
break;
@@ -2264,13 +2248,8 @@
before = IS_OPAQUE_LSA_ORIGINATION_BLOCKED (top->opaque);
- for (node = listhead (lsas); node; node = next)
+ for (ALL_LIST_ELEMENTS (lsas, node, next, lsa))
{
- next = node->next;
-
- if ((lsa = getdata (node)) == NULL)
- continue;
-
listnode_delete (lsas, lsa);
/*
@@ -2314,14 +2293,14 @@
ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, struct list *acks)
{
struct ospf *top;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa;
char type9_lsa_rcv = 0, type10_lsa_rcv = 0, type11_lsa_rcv = 0;
if ((top = oi_to_top (nbr->oi)) == NULL)
goto out;
- LIST_LOOP (acks, lsa, node)
+ for (ALL_LIST_ELEMENTS (acks, node, nnode, lsa))
{
switch (lsa->data->type)
{
@@ -2372,7 +2351,7 @@
/* Ok, let's start origination of Opaque-LSAs. */
delay = OSPF_MIN_LS_INTERVAL;
- LIST_LOOP (top->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (top->oiflist, node, nnode, oi))
{
if (! ospf_if_is_enable (oi)
|| ospf_nbr_count_opaque_capable (oi) == 0)
@@ -2409,13 +2388,10 @@
struct ospf_interface *oi;
unsigned long n = 0;
- for (node = listhead (area->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
{
- if ((oi = getdata (node)) == NULL)
- continue;
-
if (area->area_id.s_addr != OSPF_AREA_BACKBONE
- && oi->type == OSPF_IFTYPE_VIRTUALLINK)
+ && oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
n = ospf_opaque_nrxmt_self (oi->nbrs, OSPF_OPAQUE_AREA_LSA);
@@ -2441,11 +2417,8 @@
struct ospf_interface *oi;
unsigned long n = 0;
- for (node = listhead (top->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (top->oiflist, node, oi))
{
- if ((oi = getdata (node)) == NULL)
- continue;
-
switch (oi->type)
{
case OSPF_IFTYPE_VIRTUALLINK:
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 4f18c04..8892f0e 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -350,7 +350,7 @@
auth_key = (char *) "";
else
{
- ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail);
+ ck = listgetdata (listtail(OSPF_IF_PARAM (oi, auth_crypt)));
auth_key = (char *) ck->auth_key;
}
@@ -588,7 +588,7 @@
node = listhead (ospf->oi_write_q);
assert (node);
- oi = getdata (node);
+ oi = listgetdata (node);
assert (oi);
#ifdef WANT_OSPF_WRITE_FRAGMENT
@@ -1579,12 +1579,11 @@
void
ospf_upd_list_clean (struct list *lsas)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa;
- for (node = listhead (lsas); node; nextnode (node))
- if ((lsa = getdata (node)) != NULL)
- ospf_lsa_discard (lsa);
+ for (ALL_LIST_ELEMENTS (lsas, node, nnode, lsa))
+ ospf_lsa_discard (lsa);
list_delete (lsas);
}
@@ -1599,7 +1598,7 @@
#ifdef HAVE_OPAQUE_LSA
struct list *mylsa_acks, *mylsa_upds;
#endif /* HAVE_OPAQUE_LSA */
- struct listnode *node, *next;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa = NULL;
/* unsigned long ls_req_found = 0; */
@@ -1659,15 +1658,11 @@
continue; }
/* Process each LSA received in the one packet. */
- for (node = listhead (lsas); node; node = next)
+ for (ALL_LIST_ELEMENTS (lsas, node, nnode, lsa))
{
struct ospf_lsa *ls_ret, *current;
int ret = 1;
- next = node->next;
-
- lsa = getdata (node);
-
if (IS_DEBUG_OSPF_NSSA)
{
char buf1[INET_ADDRSTRLEN];
@@ -1794,12 +1789,12 @@
if(lsa->data->type == OSPF_NETWORK_LSA)
{
- struct listnode *oi_node;
+ struct listnode *oinode, *oinnode;
+ struct ospf_interface *out_if;
int Flag = 0;
- for(oi_node = listhead(oi->ospf->oiflist); oi_node; oi_node = nextnode(oi_node))
+ for (ALL_LIST_ELEMENTS (oi->ospf->oiflist, oinode, oinnode, out_if))
{
- struct ospf_interface *out_if = getdata(oi_node);
if(out_if == NULL)
break;
@@ -2126,11 +2121,8 @@
iph->ip_dst)) == NULL)
return NULL;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
- if ((vl_data = getdata (node)) == NULL)
- continue;
-
vl_area = ospf_area_lookup_by_area_id (ospf, vl_data->vl_area_id);
if (!vl_area)
continue;
@@ -2210,7 +2202,7 @@
ret = 0;
break;
case OSPF_AUTH_CRYPTOGRAPHIC:
- if ((ck = getdata (OSPF_IF_PARAM (oi,auth_crypt)->tail)) == NULL)
+ if ((ck = listgetdata (listtail(OSPF_IF_PARAM (oi,auth_crypt)))) == NULL)
{
ret = 0;
break;
@@ -2565,7 +2557,7 @@
}
else
{
- ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail);
+ ck = listgetdata (listtail(OSPF_IF_PARAM (oi, auth_crypt)));
ospfh->u.crypt.zero = 0;
ospfh->u.crypt.key_id = ck->key_id;
ospfh->u.crypt.auth_data_len = OSPF_AUTH_MD5_SIZE;
@@ -2869,8 +2861,8 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_make_ls_upd: List Iteration");
- lsa = getdata (node);
- assert (lsa);
+ lsa = listgetdata (node);
+
assert (lsa->data);
/* Will it fit? */
@@ -2915,9 +2907,9 @@
rm_list = list_new ();
- for (node = listhead (ack); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ack, node, lsa))
{
- lsa = getdata (node);
+ lsa = listgetdata (node);
assert (lsa);
if (length + delta > ospf_packet_max (oi))
@@ -2930,10 +2922,11 @@
}
/* Remove LSA from LS-Ack list. */
- for (node = listhead (rm_list); node; nextnode (node))
+ /* XXX: this loop should be removed and the list move done in previous
+ * loop
+ */
+ for (ALL_LIST_ELEMENTS_RO (rm_list, node, lsa))
{
- lsa = (struct ospf_lsa *) getdata (node);
-
listnode_delete (ack, lsa);
ospf_lsa_unlock (lsa);
}
@@ -3251,9 +3244,7 @@
size_t size;
static char warned = 0;
- ln = listhead (update);
- lsa = getdata (ln);
- assert (lsa);
+ lsa = listgetdata((ln = listhead (update)));
assert (lsa->data);
if ((OSPF_LS_UPD_MIN_SIZE + ntohs (lsa->data->length))
@@ -3391,9 +3382,10 @@
ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag)
{
struct ospf_interface *oi;
+ struct ospf_lsa *lsa;
struct prefix_ipv4 p;
struct route_node *rn;
- struct listnode *n;
+ struct listnode *node;
oi = nbr->oi;
@@ -3428,8 +3420,11 @@
if (rn->info == NULL)
rn->info = list_new ();
- for (n = listhead (update); n; nextnode (n))
- listnode_add (rn->info, ospf_lsa_lock (getdata (n)));
+ for (ALL_LIST_ELEMENTS_RO (update, node, lsa))
+ {
+ ospf_lsa_lock (lsa);
+ listnode_add (rn->info, lsa);
+ }
if (oi->t_ls_upd_event == NULL)
oi->t_ls_upd_event =
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index cf55bf0..ca39d9b 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -158,10 +158,10 @@
/* 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;
@@ -279,7 +279,7 @@
struct prefix_ipv4 p;
struct ospf_path *path;
struct vertex_nexthop *nexthop;
- struct listnode *nnode;
+ struct listnode *node, *nnode;
p.family = AF_INET;
p.prefix = v->id;
@@ -306,9 +306,8 @@
{
or->type = OSPF_DESTINATION_NETWORK;
- LIST_LOOP (v->nexthop, nexthop, nnode)
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nexthop))
{
- nexthop = getdata (nnode);
path = ospf_path_new ();
path->nexthop = nexthop->router;
listnode_add (or->paths, path);
@@ -677,11 +676,8 @@
BUFSIZ),
ospf_path_type_str[or->path_type],
or->cost);
- for (pnode = listhead (or->paths); pnode; nextnode (pnode))
- {
- path = getdata (pnode);
- zlog_debug (" -> %s", inet_ntoa (path->nexthop));
- }
+ for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
+ zlog_debug (" -> %s", inet_ntoa (path->nexthop));
}
else
zlog_debug ("R %s\t%s\t%s\t%d",
@@ -698,9 +694,9 @@
ospf_terminate ()
{
struct ospf *ospf;
- struct listnode *node;
+ struct listnode *node, *nnode;
- LIST_LOOP (om->ospf, ospf, node)
+ for (ALL_LIST_ELEMENTS (om->ospf, node, nnode, ospf))
{
if (ospf->new_table)
ospf_route_delete (ospf->new_table);
@@ -786,16 +782,13 @@
ospf_path_exist (struct list *plist, struct in_addr nexthop,
struct ospf_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_path *path;
- for (node = listhead (plist); node; nextnode (node))
- {
- path = node->data;
+ for (ALL_LIST_ELEMENTS (plist, node, nnode, path))
+ if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) && path->oi == oi)
+ return 1;
- if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) && path->oi == oi)
- return 1;
- }
return 0;
}
@@ -803,16 +796,14 @@
ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
struct vertex *v)
{
- struct listnode *nnode;
+ struct listnode *node;
struct ospf_path *path;
struct vertex_nexthop *nexthop;
assert (to->paths);
- for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nexthop))
{
- nexthop = getdata (nnode);
-
if (nexthop->oi != NULL)
{
if (! ospf_path_exist (to->paths, nexthop->router, nexthop->oi))
@@ -830,15 +821,12 @@
ospf_path_lookup (struct list *plist, struct ospf_path *path)
{
struct listnode *node;
+ struct ospf_path *op;
- for (node = listhead (plist); node; nextnode (node))
- {
- struct ospf_path *op = node->data;
-
- if (IPV4_ADDR_SAME (&op->nexthop, &path->nexthop) &&
- IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
- return op;
- }
+ for (ALL_LIST_ELEMENTS_RO (plist, node, op))
+ if (IPV4_ADDR_SAME (&op->nexthop, &path->nexthop) &&
+ IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
+ return op;
return NULL;
}
@@ -846,14 +834,15 @@
void
ospf_route_copy_nexthops (struct ospf_route *to, struct list *from)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_path *path;
assert (to->paths);
- for (node = listhead (from); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (from, node, nnode, path))
/* The same routes are just discarded. */
- if (!ospf_path_lookup (to->paths, node->data))
- listnode_add (to->paths, ospf_path_dup (node->data));
+ if (!ospf_path_lookup (to->paths, path))
+ listnode_add (to->paths, ospf_path_dup (path));
}
void
@@ -931,7 +920,7 @@
{
struct route_node *rn, *next;
struct ospf_route *or;
- struct listnode *node, *nnext;
+ struct listnode *node, *nnode;
struct list *paths;
if (IS_DEBUG_OSPF_EVENT)
@@ -943,12 +932,8 @@
if ((paths = rn->info) == NULL)
continue;
- for (node = listhead (paths); node; node = nnext)
+ for (ALL_LIST_ELEMENTS (paths, node, nnode, or))
{
- nnext = node->next;
-
- or = getdata (node);
-
if (listcount (or->paths) == 0)
{
if (IS_DEBUG_OSPF_EVENT)
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index c1994ab..4ed1fab 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -499,13 +499,10 @@
if (ospf == NULL)
return 0;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- oi = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi && oi->address)
+ return 1;
- if (oi && oi->address)
- return 1;
- }
return 0;
}
@@ -624,16 +621,14 @@
node = listhead (ospf->areas);
if (node)
{
- area = getdata (node);
+ area = listgetdata (node);
*area_id = area->area_id;
return area;
}
return NULL;
}
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr))
{
*area_id = area->area_id;
@@ -757,10 +752,8 @@
if (ospf == NULL)
return NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (area->external_routing == OSPF_AREA_STUB)
{
if (first)
@@ -1401,14 +1394,14 @@
void
ospf_snmp_if_delete (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ospf_snmp_if *osif;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS (ospf_snmp_iflist, node, nnode, osif))
{
if (osif->ifp == ifp)
{
- list_delete_node (ospf_snmp_iflist, nn);
+ list_delete_node (ospf_snmp_iflist, node);
ospf_snmp_if_free (osif);
return;
}
@@ -1418,7 +1411,7 @@
void
ospf_snmp_if_update (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node;
struct listnode *pn;
struct connected *ifc;
struct prefix *p;
@@ -1433,7 +1426,7 @@
ifindex = 0;
/* Lookup first IPv4 address entry. */
- LIST_LOOP (ifp->connected, ifc, nn)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
if (CONNECTED_POINTOPOINT_HOST(ifc))
p = ifc->destination;
@@ -1451,7 +1444,7 @@
/* Add interface to the list. */
pn = NULL;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
{
if (addr)
{
@@ -1464,7 +1457,7 @@
if (osif->addr.s_addr != 0 || osif->ifindex > ifindex)
break;
}
- pn = nn;
+ pn = node;
}
osif = ospf_snmp_if_new ();
@@ -1480,10 +1473,10 @@
struct interface *
ospf_snmp_if_lookup (struct in_addr *ifaddr, unsigned int *ifindex)
{
- struct listnode *nn;
+ struct listnode *node;
struct ospf_snmp_if *osif;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
{
if (ifaddr->s_addr)
{
@@ -1511,7 +1504,7 @@
nn = listhead (ospf_snmp_iflist);
if (nn)
{
- osif = getdata (nn);
+ osif = listgetdata (nn);
*ifaddr = osif->addr;
*ifindex = osif->ifindex;
return osif->ifp;
@@ -1519,7 +1512,7 @@
return NULL;
}
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, nn, osif))
{
if (ifaddr->s_addr)
{
@@ -2051,12 +2044,12 @@
ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
unsigned int *ifindex)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf_neighbor *nbr;
struct route_node *rn;
- LIST_LOOP (ospf->oiflist, oi, nn)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
@@ -2086,7 +2079,8 @@
struct ospf *ospf = ospf;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->oiflist, oi, nn)
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, nn, oi))
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index 9a4e8ff..c69fc7f 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -125,13 +125,14 @@
void
ospf_vertex_free (struct vertex *v)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct vertex_nexthop *nh;
list_delete (v->child);
if (listcount (v->nexthop) > 0)
- for (node = listhead (v->nexthop); node; nextnode (node))
- vertex_nexthop_free (node->data);
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nh))
+ vertex_nexthop_free (nh);
list_delete (v->nexthop);
@@ -155,14 +156,14 @@
if (print_nexthops)
{
- struct listnode *nnode;
- for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
+ struct listnode *node;
+ struct vertex_nexthop *nexthop;
+
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nexthop))
{
char buf1[BUFSIZ];
char buf2[BUFSIZ];
- struct vertex_nexthop *nexthop;
- nexthop = getdata (nnode);
if (nexthop)
{
zlog_debug (" nexthop %s interface %s parent %s",
@@ -179,12 +180,10 @@
if (print_children)
{
struct listnode *cnode;
- for (cnode = listhead (v->child); cnode; nextnode (cnode))
- {
- struct vertex *cv = getdata (cnode);
- if (cv)
- ospf_vertex_dump(" child:", cv, 0, 0);
- }
+ struct vertex *cv;
+
+ for (ALL_LIST_ELEMENTS_RO (v->child, cnode, cv))
+ ospf_vertex_dump(" child:", cv, 0, 0);
}
}
@@ -196,10 +195,8 @@
struct vertex_nexthop *nh;
struct listnode *node;
- for (node = listhead (v->nexthop); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nh))
{
- nh = (struct vertex_nexthop *) getdata (node);
-
/* No need to add two links from the same parent. */
if (listnode_lookup (nh->parent->child, v) == NULL)
listnode_add (nh->parent->child, v);
@@ -296,10 +293,9 @@
int match;
match = 0;
- for (node = listhead (nexthop); node; nextnode (node))
- {
- nh = node->data;
+ for (ALL_LIST_ELEMENTS_RO (nexthop, node, nh))
+ {
/* Compare the two entries. */
/* XXX
* Comparing the parent preserves the shortest path tree
@@ -324,12 +320,11 @@
void
ospf_nexthop_merge (struct list *a, struct list *b)
{
- struct listnode *n;
+ struct listnode *node, *nnode;
+ struct vertex_nexthop *nh;
- for (n = listhead (b); n; nextnode (n))
- {
- ospf_nexthop_add_unique (n->data, a);
- }
+ for (ALL_LIST_ELEMENTS (b, node, nnode, nh))
+ ospf_nexthop_add_unique (nh, a);
}
#define ROUTER_LSA_MIN_SIZE 12
@@ -407,17 +402,14 @@
*/
if (nexthops->head != NULL)
{
- hop = getdata (nexthops->head);
+ hop = listgetdata (nexthops->head);
/* weed out hops with higher cost than the newhop */
if (hop->oi->output_cost > newhop->oi->output_cost)
{
/* delete the existing nexthops */
- for (ln = nexthops->head; ln; ln = nn)
+ for (ALL_LIST_ELEMENTS (nexthops, ln, nn, hop))
{
- nn = ln->next;
- hop = getdata (ln);
-
listnode_delete (nexthops, hop);
vertex_nexthop_free (hop);
}
@@ -439,7 +431,7 @@
ospf_nexthop_calculation (struct ospf_area *area,
struct vertex *v, struct vertex *w)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct vertex_nexthop *nh, *x;
struct ospf_interface *oi = NULL;
struct router_lsa_link *l = NULL;
@@ -473,11 +465,13 @@
if (IS_DEBUG_OSPF_EVENT)
{
char buf1[BUFSIZ];
+ char buf2[BUFSIZ];
+
zlog_debug("ospf_nexthop_calculation(): considering link "
"type %d link_id %s link_data %s",
l->m[0].type,
inet_ntop (AF_INET, &l->link_id, buf1, BUFSIZ),
- inet_ntop (AF_INET, &l->link_data, buf1, BUFSIZ));
+ inet_ntop (AF_INET, &l->link_data, buf2, BUFSIZ));
}
if (l->m[0].type == LSA_LINK_TYPE_POINTOPOINT)
@@ -580,9 +574,8 @@
else if (v->type == OSPF_VERTEX_NETWORK)
{
/* See if any of V's parents are the root. */
- for (node = listhead (v->nexthop); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, x))
{
- x = (struct vertex_nexthop *) getdata (node);
if (x->parent == area->spf) /* connects to root? */
{
/* 16.1.1 para 5. ...the parent vertex is a network that
@@ -615,9 +608,8 @@
* destination simply inherits the set of next hops from the
* parent.
*/
- for (node = listhead (v->nexthop); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nh))
{
- nh = vertex_nexthop_dup (node->data);
nh->parent = v;
ospf_nexthop_add_unique (nh, w->nexthop);
}
@@ -843,20 +835,14 @@
ip_masklen (lsa->mask));
}
- for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
- {
- nexthop = getdata (nnode);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug (" nexthop %s", inet_ntoa (nexthop->router));
- }
+ if (IS_DEBUG_OSPF_EVENT)
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, nnode, nexthop))
+ zlog_debug (" nexthop %s", inet_ntoa (nexthop->router));
i++;
- for (cnode = listhead (v->child); cnode; nextnode (cnode))
- {
- v = getdata (cnode);
- ospf_spf_dump (v, i);
- }
+ for (ALL_LIST_ELEMENTS_RO (v->child, cnode, v))
+ ospf_spf_dump (v, i);
}
/* Second stage of SPF calculation. */
@@ -864,7 +850,7 @@
ospf_spf_process_stubs (struct ospf_area *area, struct vertex *v,
struct route_table *rt)
{
- struct listnode *cnode;
+ struct listnode *cnode, *cnnode;
struct vertex *child;
if (IS_DEBUG_OSPF_EVENT)
@@ -903,10 +889,8 @@
ospf_vertex_dump("ospf_process_stubs(): after examining links: ", v, 1, 1);
- for (cnode = listhead (v->child); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS (v->child, cnode, cnnode, child))
{
- child = getdata (cnode);
-
if (CHECK_FLAG (child->flags, OSPF_VERTEX_PROCESSED))
continue;
@@ -921,7 +905,8 @@
{
struct route_node *rn;
struct list *or_list;
- struct listnode *node;
+ struct ospf_route *or;
+ struct listnode *node, *nnode;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Route: Router Routing Table free");
@@ -929,8 +914,8 @@
for (rn = route_top (rtrs); rn; rn = route_next (rn))
if ((or_list = rn->info) != NULL)
{
- for (node = listhead (or_list); node; nextnode (node))
- ospf_route_free (node->data);
+ for (ALL_LIST_ELEMENTS (or_list, node, nnode, or))
+ ospf_route_free (or);
list_delete (or_list);
@@ -958,10 +943,8 @@
for (rn = route_top (rtrs); rn; rn = route_next (rn))
if ((or_list = rn->info) != NULL)
- for (ln = listhead (or_list); ln; nextnode (ln))
+ for (ALL_LIST_ELEMENTS_RO (or_list, ln, or))
{
- or = getdata (ln);
-
switch (or->path_type)
{
case OSPF_PATH_INTRA_AREA:
@@ -982,9 +965,8 @@
break;
}
- for (pnode = listhead (or->paths); pnode; nextnode (pnode))
+ for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
{
- path = getdata (pnode);
if (path->nexthop.s_addr == 0)
{
if (IS_DEBUG_OSPF_EVENT)
@@ -1118,7 +1100,8 @@
{
struct ospf *ospf = THREAD_ARG (thread);
struct route_table *new_table, *new_rtrs;
- struct listnode *node;
+ struct ospf_area *area;
+ struct listnode *node, *nnode;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("SPF: Timer (SPF calculation expire)");
@@ -1132,8 +1115,8 @@
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);
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ ospf_spf_calculate (area, new_table, new_rtrs);
ospf_vl_shut_unapproved (ospf);
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 0b04c96..582dc43 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -252,10 +252,10 @@
static struct mpls_te_link *
lookup_linkparams_by_ifp (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
if (lp->ifp == ifp)
return lp;
@@ -269,7 +269,7 @@
struct mpls_te_link *lp;
unsigned int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS_RO (OspfMplsTE.iflist, node, lp))
if (lp->instance == key)
return lp;
@@ -282,11 +282,12 @@
void (*func)(struct mpls_te_link *lp, enum sched_opcode),
enum sched_opcode sched_opcode)
{
- struct listnode *node, *node2;
+ struct listnode *node, *nnode;
+ struct listnode *node2;
struct mpls_te_link *lp;
struct ospf_area *area;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if ((area = lp->area) == NULL)
continue;
@@ -296,14 +297,14 @@
if (func != NULL)
(* func)(lp, sched_opcode);
- for (node2 = nextnode (node); node2; nextnode (node2))
- if ((lp = getdata (node2)) != NULL)
+ for (node2 = listnextnode (node); node2; node2 = listnextnode (node2))
+ if ((lp = listgetdata (node2)) != NULL)
if (lp->area != NULL)
if (IPV4_ADDR_SAME (&lp->area->area_id, &area->area_id))
lp->flags |= LPFLG_LOOKUP_DONE;
}
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS_RO (OspfMplsTE.iflist, node, lp))
if (lp->area != NULL)
lp->flags &= ~LPFLG_LOOKUP_DONE;
@@ -965,7 +966,7 @@
ospf_mpls_te_lsa_originate (void *arg)
{
struct ospf_area *area = (struct ospf_area *) arg;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
int rc = -1;
@@ -976,10 +977,8 @@
goto out;
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
- if ((lp = getdata (node)) == NULL)
- continue;
if (lp->area == NULL)
continue;
if (! IPV4_ADDR_SAME (&lp->area->area_id, &area->area_id))
@@ -1471,7 +1470,7 @@
"Configure MPLS-TE parameters\n"
"Enable the MPLS-TE functionality\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == enabled)
@@ -1488,9 +1487,8 @@
* 1) MPLS-TE was disabled at startup time, but now become enabled.
* 2) MPLS-TE was once enabled then disabled, and now enabled again.
*/
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- initialize_linkparams (lp);
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
+ initialize_linkparams (lp);
ospf_mpls_te_foreach_area (ospf_mpls_te_lsa_schedule, REORIGINATE_PER_AREA);
@@ -1510,7 +1508,7 @@
"Configure MPLS-TE parameters\n"
"Disable the MPLS-TE functionality\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == disabled)
@@ -1521,11 +1519,10 @@
OspfMplsTE.status = disabled;
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- if (lp->area != NULL)
- if (lp->flags & LPFLG_LSA_ENGAGED)
- ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA);
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
+ if (lp->area != NULL)
+ if (lp->flags & LPFLG_LSA_ENGAGED)
+ ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA);
return CMD_SUCCESS;
}
@@ -1549,7 +1546,7 @@
if (ntohs (ra->header.type) == 0
|| ntohl (ra->value.s_addr) != ntohl (value.s_addr))
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
int need_to_reoriginate = 0;
@@ -1558,7 +1555,7 @@
if (OspfMplsTE.status == disabled)
goto out;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if (lp->area == NULL)
continue;
@@ -1569,8 +1566,8 @@
break;
}
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if (lp->area == NULL)
continue;
@@ -1868,13 +1865,13 @@
"Interface name\n")
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Show All Interfaces. */
if (argc == 0)
{
- LIST_LOOP (iflist, ifp, node)
- show_mpls_te_link_sub (vty, ifp);
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ show_mpls_te_link_sub (vty, ifp);
}
/* Interface name is specified. */
else
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index c0e1f6c..55b3315 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -2319,6 +2319,7 @@
struct ospf *ospf = vty->index;
u_int32_t refbw;
struct listnode *node;
+ struct interface *ifp;
refbw = strtol (argv[0], NULL, 10);
if (refbw < 1 || refbw > 4294967)
@@ -2335,8 +2336,8 @@
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 (om->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
+ ospf_if_recalculate_output_cost (ifp);
return CMD_SUCCESS;
}
@@ -2349,7 +2350,8 @@
"Use reference bandwidth method to assign OSPF cost\n")
{
struct ospf *ospf = vty->index;
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct interface *ifp;
if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
return CMD_SUCCESS;
@@ -2358,8 +2360,8 @@
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 (om->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
+ for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
+ ospf_if_recalculate_output_cost (ifp);
return CMD_SUCCESS;
}
@@ -2499,7 +2501,7 @@
IP_STR
"OSPF information\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_area * area;
struct ospf *ospf;
@@ -2562,9 +2564,8 @@
listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
/* Show each area status. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- show_ip_ospf_area (vty, area);
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ show_ip_ospf_area (vty, area);
return CMD_SUCCESS;
}
@@ -2708,8 +2709,8 @@
/* Show All Interfaces. */
if (argc == 0)
- for (node = listhead (iflist); node; nextnode (node))
- show_ip_ospf_interface_sub (vty, ospf, node->data);
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ show_ip_ospf_interface_sub (vty, ospf, ifp);
/* Interface name is specified. */
else
{
@@ -2764,6 +2765,7 @@
"Neighbor list\n")
{
struct ospf *ospf;
+ struct ospf_interface *oi;
struct listnode *node;
ospf = ospf_lookup ();
@@ -2778,8 +2780,8 @@
"Time Address Interface RXmtL "
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- show_ip_ospf_neighbor_sub (vty, getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ show_ip_ospf_neighbor_sub (vty, oi);
return CMD_SUCCESS;
}
@@ -2795,6 +2797,7 @@
{
struct ospf *ospf = vty->index;
struct listnode *node;
+ struct ospf_interface *oi;
if (ospf == NULL)
{
@@ -2807,20 +2810,16 @@
"Time Address Interface RXmtL "
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
struct listnode *nbr_node;
+ struct ospf_nbr_nbma *nbr_nbma;
show_ip_ospf_neighbor_sub (vty, oi);
/* print Down neighbor status */
- for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
+ for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
{
- struct ospf_nbr_nbma *nbr_nbma;
-
- nbr_nbma = getdata (nbr_node);
-
if (nbr_nbma->nbr == NULL
|| nbr_nbma->nbr->state == NSM_Down)
{
@@ -2980,6 +2979,7 @@
struct ospf *ospf;
struct listnode *node;
struct ospf_neighbor *nbr;
+ struct ospf_interface *oi;
struct in_addr router_id;
int ret;
@@ -2997,16 +2997,12 @@
return CMD_SUCCESS;
}
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
- {
- show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
- return CMD_SUCCESS;
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
+ {
+ show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
+ return CMD_SUCCESS;
+ }
/* Nothing to show. */
return CMD_SUCCESS;
@@ -3022,6 +3018,7 @@
"detail of all neighbors\n")
{
struct ospf *ospf;
+ struct ospf_interface *oi;
struct listnode *node;
ospf = ospf_lookup ();
@@ -3031,9 +3028,8 @@
return CMD_SUCCESS;
}
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
struct route_node *rn;
struct ospf_neighbor *nbr;
@@ -3059,6 +3055,7 @@
{
struct ospf *ospf;
struct listnode *node;
+ struct ospf_interface *oi;
ospf = ospf_lookup ();
if (ospf == NULL)
@@ -3067,11 +3064,11 @@
return CMD_SUCCESS;
}
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
struct route_node *rn;
struct ospf_neighbor *nbr;
+ struct ospf_nbr_nbma *nbr_nbma;
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info))
@@ -3083,13 +3080,10 @@
{
struct listnode *nd;
- for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
- {
- struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
- if (nbr_nbma->nbr == NULL
- || nbr_nbma->nbr->state == NSM_Down)
- show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
+ if (nbr_nbma->nbr == NULL
+ || nbr_nbma->nbr->state == NSM_Down)
+ show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
}
}
@@ -3609,7 +3603,8 @@
struct in_addr *id, struct in_addr *adv_router)
{
struct listnode *node;
-
+ struct ospf_area *area;
+
switch (type)
{
case OSPF_AS_EXTERNAL_LSA:
@@ -3622,9 +3617,8 @@
show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
break;
default:
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = node->data;
vty_out (vty, "%s %s (Area %s)%s%s",
VTY_NEWLINE, show_database_desc[type],
ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
@@ -3658,6 +3652,7 @@
struct in_addr *adv_router)
{
struct listnode *node;
+ struct ospf_area *area;
switch (type)
{
@@ -3672,9 +3667,8 @@
adv_router);
break;
default:
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = node->data;
vty_out (vty, "%s %s (Area %s)%s%s",
VTY_NEWLINE, show_database_desc[type],
ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
@@ -3690,12 +3684,12 @@
{
struct ospf_lsa *lsa;
struct route_node *rn;
+ struct ospf_area *area;
struct listnode *node;
int type;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = node->data;
for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
{
switch (type)
@@ -3765,17 +3759,16 @@
vty_out (vty, "%s MaxAge Link States:%s%s",
VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- 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);
- vty_out (vty, "Link State ID: %s%s",
- inet_ntoa (lsa->data->id), VTY_NEWLINE);
- vty_out (vty, "Advertising Router: %s%s",
- inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
- vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
+ {
+ vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
+ vty_out (vty, "Link State ID: %s%s",
+ inet_ntoa (lsa->data->id), VTY_NEWLINE);
+ vty_out (vty, "Advertising Router: %s%s",
+ inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
+ vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
}
#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
@@ -6509,7 +6502,7 @@
{
struct route_node *rn;
struct ospf_route *or;
- struct listnode *pnode;
+ struct listnode *pnode, *pnnode;
struct ospf_path *path;
vty_out (vty, "============ OSPF network routing table ============%s",
@@ -6540,7 +6533,7 @@
}
if (or->type == OSPF_DESTINATION_NETWORK)
- LIST_LOOP (or->paths, path, pnode)
+ for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
{
if (path->oi != NULL)
{
@@ -6562,7 +6555,8 @@
{
struct route_node *rn;
struct ospf_route *or;
- struct listnode *pn, *nn;
+ struct listnode *pnode;
+ struct listnode *node;
struct ospf_path *path;
vty_out (vty, "============ OSPF router routing table =============%s",
@@ -6574,33 +6568,32 @@
vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
- for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
- if ((or = getdata (nn)) != NULL)
- {
- if (flag++)
- vty_out (vty, "%24s", "");
+ for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
+ {
+ if (flag++)
+ vty_out (vty, "%24s", "");
- /* Show path. */
- vty_out (vty, "%s [%d] area: %s",
- (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
- or->cost, inet_ntoa (or->u.std.area_id));
- /* Show flags. */
- vty_out (vty, "%s%s%s",
- (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
- (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
- VTY_NEWLINE);
-
- LIST_LOOP (or->paths, path, pn)
- {
- if (path->nexthop.s_addr == 0)
- vty_out (vty, "%24s directly attached to %s%s",
- "", path->oi->ifp->name, VTY_NEWLINE);
- else
- vty_out (vty, "%24s via %s, %s%s", "",
- inet_ntoa (path->nexthop), path->oi->ifp->name,
- VTY_NEWLINE);
- }
- }
+ /* Show path. */
+ vty_out (vty, "%s [%d] area: %s",
+ (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
+ or->cost, inet_ntoa (or->u.std.area_id));
+ /* Show flags. */
+ vty_out (vty, "%s%s%s",
+ (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
+ (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
+ VTY_NEWLINE);
+
+ for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
+ {
+ if (path->nexthop.s_addr == 0)
+ vty_out (vty, "%24s directly attached to %s%s",
+ "", path->oi->ifp->name, VTY_NEWLINE);
+ else
+ vty_out (vty, "%24s via %s, %s%s", "",
+ inet_ntoa (path->nexthop), path->oi->ifp->name,
+ VTY_NEWLINE);
+ }
+ }
}
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -6610,7 +6603,7 @@
{
struct route_node *rn;
struct ospf_route *er;
- struct listnode *pnode;
+ struct listnode *pnode, *pnnode;
struct ospf_path *path;
vty_out (vty, "============ OSPF external routing table ===========%s",
@@ -6634,7 +6627,7 @@
break;
}
- LIST_LOOP (er->paths, path, pnode)
+ for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
{
if (path->oi != NULL)
{
@@ -6770,10 +6763,8 @@
struct route_node *rn = NULL;
struct ospf_if_params *params;
- for (n1 = listhead (iflist); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
{
- ifp = getdata (n1);
-
if (memcmp (ifp->name, "VLINK", 5) == 0)
continue;
@@ -6849,9 +6840,8 @@
}
/* Cryptographic Authentication Key print. */
- for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
+ for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
{
- ck = getdata (n2);
vty_out (vty, " ip ospf message-digest-key %d md5 %s",
ck->key_id, ck->auth_key);
if (params != IF_DEF_PARAMS (ifp))
@@ -6977,12 +6967,12 @@
config_write_ospf_area (struct vty *vty, struct ospf *ospf)
{
struct listnode *node;
+ struct ospf_area *area;
u_char buf[INET_ADDRSTRLEN];
/* Area configuration print. */
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = getdata (node);
struct route_node *rn1;
area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
@@ -7103,14 +7093,14 @@
config_write_virtual_link (struct vty *vty, struct ospf *ospf)
{
struct listnode *node;
+ struct ospf_vl_data *vl_data;
u_char buf[INET_ADDRSTRLEN];
/* Virtual-Link print */
- for (node = listhead (ospf->vlinks); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
struct listnode *n2;
struct crypt_key *ck;
- struct ospf_vl_data *vl_data = getdata (node);
struct ospf_interface *oi;
if (vl_data != NULL)
@@ -7148,14 +7138,13 @@
IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
VTY_NEWLINE);
/* md5 keys */
- for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
- {
- ck = getdata (n2);
- vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
- buf,
- inet_ntoa (vl_data->vl_peer),
- ck->key_id, ck->auth_key, VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
+ n2, ck))
+ vty_out (vty, " area %s virtual-link %s"
+ " message-digest-key %d md5 %s%s",
+ buf,
+ inet_ntoa (vl_data->vl_peer),
+ ck->key_id, ck->auth_key, VTY_NEWLINE);
}
}
@@ -7281,6 +7270,8 @@
ospf_config_write (struct vty *vty)
{
struct ospf *ospf;
+ struct interface *ifp;
+ struct ospf_interface *oi;
struct listnode *node;
int write = 0;
@@ -7329,28 +7320,17 @@
config_write_ospf_redistribute (vty, ospf);
/* passive-interface print. */
- for (node = listhead (om->iflist); node; nextnode (node))
- {
- struct interface *ifp = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
+ if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
+ vty_out (vty, " passive-interface %s%s",
+ ifp->name, VTY_NEWLINE);
- if (!ifp)
- continue;
- if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
- vty_out (vty, " passive-interface %s%s",
- ifp->name, VTY_NEWLINE);
- }
-
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
- oi->params->passive_interface == OSPF_IF_PASSIVE)
- vty_out (vty, " passive-interface %s %s%s",
- oi->ifp->name,
- inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
- }
-
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
+ oi->params->passive_interface == OSPF_IF_PASSIVE)
+ vty_out (vty, " passive-interface %s %s%s",
+ oi->ifp->name,
+ inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
/* Network area print. */
config_write_network_area (vty, ospf);
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 27299c5..e8513b3 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -359,10 +359,8 @@
stream_putc (s, or->paths->count);
/* Nexthop, ifindex, distance and metric information. */
- for (node = listhead (or->paths); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (or->paths, node, path))
{
- path = getdata (node);
-
if (path->nexthop.s_addr != INADDR_ANY)
{
stream_putc (s, ZEBRA_NEXTHOP_IPV4);
@@ -409,7 +407,7 @@
struct zapi_ipv4 api;
struct ospf_path *path;
struct in_addr *nexthop;
- struct listnode *node;
+ struct listnode *node, *nnode;
if (zclient->redist[ZEBRA_ROUTE_OSPF])
{
@@ -419,10 +417,8 @@
api.ifindex_num = 0;
api.nexthop_num = 0;
- for (node = listhead (or->paths); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path))
{
- path = getdata (node);
-
if (path->nexthop.s_addr != INADDR_ANY)
{
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
@@ -1027,21 +1023,20 @@
}
/* Update Area access-list. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- {
- if (EXPORT_NAME (area))
- {
- EXPORT_LIST (area) = NULL;
- abr_inv++;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ {
+ if (EXPORT_NAME (area))
+ {
+ EXPORT_LIST (area) = NULL;
+ abr_inv++;
+ }
- if (IMPORT_NAME (area))
- {
- IMPORT_LIST (area) = NULL;
- abr_inv++;
- }
- }
+ if (IMPORT_NAME (area))
+ {
+ IMPORT_LIST (area) = NULL;
+ abr_inv++;
+ }
+ }
/* Schedule ABR tasks -- this will be changed -- takada. */
if (IS_OSPF_ABR (ospf) && abr_inv)
@@ -1077,27 +1072,26 @@
}
/* Update area filter-lists. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- {
- /* Update filter-list in. */
- if (PREFIX_NAME_IN (area))
- if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0)
- {
- PREFIX_LIST_IN (area) =
- prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area));
- abr_inv++;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ {
+ /* Update filter-list in. */
+ if (PREFIX_NAME_IN (area))
+ if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0)
+ {
+ PREFIX_LIST_IN (area) =
+ prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area));
+ abr_inv++;
+ }
- /* Update filter-list out. */
- if (PREFIX_NAME_OUT (area))
- if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0)
- {
- PREFIX_LIST_IN (area) =
- prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area));
- abr_inv++;
- }
- }
+ /* Update filter-list out. */
+ if (PREFIX_NAME_OUT (area))
+ if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0)
+ {
+ PREFIX_LIST_IN (area) =
+ prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area));
+ abr_inv++;
+ }
+ }
/* Schedule ABR task. */
if (IS_OSPF_ABR (ospf) && abr_inv)
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index a77fb4b..cbc3d13 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -75,6 +75,7 @@
ospf_router_id_update (struct ospf *ospf)
{
struct in_addr router_id, router_id_old;
+ struct ospf_interface *oi;
struct listnode *node;
if (IS_DEBUG_OSPF_EVENT)
@@ -94,13 +95,9 @@
if (!IPV4_ADDR_SAME (&router_id_old, &router_id))
{
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- /* Update self-neighbor's router_id. */
- oi->nbr_self->router_id = router_id;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ /* Update self-neighbor's router_id. */
+ oi->nbr_self->router_id = router_id;
/* If AS-external-LSA is queued, then flush those LSAs. */
if (router_id_old.s_addr == 0 && ospf->external_origin)
@@ -228,7 +225,7 @@
if (listcount (om->ospf) == 0)
return NULL;
- return getdata (listhead (om->ospf));
+ return listgetdata (listhead (om->ospf));
}
void
@@ -271,7 +268,10 @@
struct route_node *rn;
struct ospf_nbr_nbma *nbr_nbma;
struct ospf_lsa *lsa;
- struct listnode *node;
+ struct ospf_interface *oi;
+ struct ospf_area *area;
+ struct ospf_vl_data *vl_data;
+ struct listnode *node, *nnode;
int i;
#ifdef HAVE_OPAQUE_LSA
@@ -282,33 +282,17 @@
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
ospf_redistribute_unset (ospf, i);
- for (node = listhead (ospf->areas); node;)
- {
- struct ospf_area *area = getdata (node);
- nextnode (node);
-
- ospf_remove_vls_through_area (ospf, area);
- }
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ ospf_remove_vls_through_area (ospf, area);
- for (node = listhead (ospf->vlinks); node; )
- {
- struct ospf_vl_data *vl_data = node->data;
- nextnode (node);
-
- ospf_vl_delete (ospf, vl_data);
- }
+ for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
+ ospf_vl_delete (ospf, vl_data);
list_delete (ospf->vlinks);
/* Reset interface. */
- for (node = listhead (ospf->oiflist); node;)
- {
- struct ospf_interface *oi = getdata (node);
- nextnode (node);
-
- if (oi)
- ospf_if_free (oi);
- }
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
+ ospf_if_free (oi);
/* Clear static neighbors */
for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
@@ -346,11 +330,8 @@
}
}
- for (node = listhead (ospf->areas); node;)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = getdata (node);
- nextnode (node);
-
listnode_delete (ospf->areas, area);
ospf_area_free (area);
}
@@ -382,8 +363,8 @@
ospf_lsdb_delete_all (ospf->lsdb);
ospf_lsdb_free (ospf->lsdb);
- for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
- ospf_lsa_unlock (getdata (node));
+ for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_delete (ospf->maxage_lsa);
@@ -565,13 +546,9 @@
struct ospf_area *area;
struct listnode *node;
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- area = getdata (node);
-
- if (IPV4_ADDR_SAME (&area->area_id, &area_id))
- return area;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (IPV4_ADDR_SAME (&area->area_id, &area_id))
+ return area;
return NULL;
}
@@ -728,6 +705,7 @@
ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
{
struct interface *ifp;
+ struct connected *co;
struct listnode *node;
/* Schedule Router ID Update. */
@@ -739,21 +717,17 @@
}
/* Get target interface. */
- for (node = listhead (om->iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
{
- struct listnode *cn;
+ struct listnode *cnode;
- if ((ifp = getdata (node)) == NULL)
- continue;
-
if (memcmp (ifp->name, "VLINK", 5) == 0)
continue;
/* if interface prefix is match specified prefix,
then create socket and join multicast group. */
- for (cn = listhead (ifp->connected); cn; nextnode (cn))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, co))
{
- struct connected *co = getdata (cn);
struct prefix *addr;
if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY))
@@ -768,7 +742,7 @@
&& ! ospf_if_is_configured (ospf, &(addr->u.prefix4))
&& ospf_network_match_iface(co,p))
{
- struct ospf_interface *oi;
+ struct ospf_interface *oi;
oi = ospf_if_new (ospf, ifp, co->address);
oi->connected = co;
@@ -829,7 +803,7 @@
ospf_ls_upd_queue_empty (struct ospf_interface *oi)
{
struct route_node *rn;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct list *lst;
struct ospf_lsa *lsa;
@@ -838,9 +812,8 @@
rn = route_next (rn))
if ((lst = (struct list *) rn->info))
{
- for (node = listhead (lst); node; nextnode (node))
- if ((lsa = getdata (node)))
- ospf_lsa_unlock (lsa);
+ for (ALL_LIST_ELEMENTS (lst, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_free (lst);
rn->info = NULL;
}
@@ -857,10 +830,10 @@
ospf_if_update (struct ospf *ospf)
{
struct route_node *rn;
- struct listnode *node;
- struct listnode *next;
+ struct listnode *node, *nnode;
struct ospf_network *network;
struct ospf_area *area;
+ struct ospf_interface *oi;
if (ospf != NULL)
{
@@ -874,14 +847,11 @@
}
/* Find interfaces that not configured already. */
- for (node = listhead (ospf->oiflist); node; node = next)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
int found = 0;
- struct ospf_interface *oi = getdata (node);
struct connected *co = oi->connected;
- next = nextnode (node);
-
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
@@ -916,16 +886,12 @@
void
ospf_remove_vls_through_area (struct ospf *ospf, struct ospf_area *area)
{
- struct listnode *node, *next;
+ struct listnode *node, *nnode;
struct ospf_vl_data *vl_data;
- 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 (ospf, vl_data);
- }
+ for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
+ if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
+ ospf_vl_delete (ospf, vl_data);
}
@@ -960,40 +926,35 @@
switch (area->external_routing)
{
case OSPF_AREA_DEFAULT:
- for (node = listhead (area->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL)
- if (oi->nbr_self != NULL)
- {
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
- SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
- }
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+ if (oi->nbr_self != NULL)
+ {
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ }
break;
case OSPF_AREA_STUB:
- for (node = listhead (area->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL)
- if (oi->nbr_self != NULL)
- {
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("setting options on %s accordingly", IF_NAME (oi));
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("options set on %s: %x",
- IF_NAME (oi), OPTIONS (oi));
- }
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+ if (oi->nbr_self != NULL)
+ {
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("setting options on %s accordingly", IF_NAME (oi));
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("options set on %s: %x",
+ IF_NAME (oi), OPTIONS (oi));
+ }
break;
case OSPF_AREA_NSSA:
- for (node = listhead (area->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL)
- if (oi->nbr_self != NULL)
- {
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("setting nssa options on %s accordingly", IF_NAME (oi));
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
- SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("options set on %s: %x", IF_NAME (oi), OPTIONS (oi));
- }
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+ if (oi->nbr_self != NULL)
+ {
+ zlog_debug ("setting nssa options on %s accordingly", IF_NAME (oi));
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ zlog_debug ("options set on %s: %x", IF_NAME (oi), OPTIONS (oi));
+ }
break;
default:
break;
@@ -1036,12 +997,9 @@
struct listnode *node;
int count = 0;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
- {
- vl = getdata (node);
- if (IPV4_ADDR_SAME (&vl->vl_area_id, &area->area_id))
- count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl))
+ if (IPV4_ADDR_SAME (&vl->vl_area_id, &area->area_id))
+ count++;
return count;
}
@@ -1474,10 +1432,8 @@
return NULL;
#if 0
- for (node = listhead (ospf->nbr_nbma); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->nbr_nbma, node, nbr_nbma))
{
- nbr_nbma = getdata (node);
-
if (first)
{
*addr = nbr_nbma->addr;
@@ -1516,9 +1472,8 @@
rn = route_node_get (ospf->nbr_nbma, (struct prefix *)&p);
rn->info = nbr_nbma;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- oi = getdata (node);
if (oi->type == OSPF_IFTYPE_NBMA)
if (prefix_match (oi->address, (struct prefix *)&p))
{