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/ripd/ripd.c b/ripd/ripd.c
index afdcd83..3dd91da 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -365,13 +365,10 @@
/* If nexthop address matches local configured address then it is
invalid nexthop. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, ifc))
{
- ifc = getdata (cnode);
p = ifc->address;
if (p->family == AF_INET
@@ -2440,7 +2437,8 @@
void
rip_update_process (int route_type)
{
- struct listnode *node, *ifnode;
+ struct listnode *node;
+ struct listnode *ifnode, *ifnnode;
struct connected *connected;
struct interface *ifp;
struct rip_interface *ri;
@@ -2449,10 +2447,8 @@
struct prefix_ipv4 *p;
/* Send RIP update to each interface. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
if (if_is_loopback (ifp))
continue;
@@ -2480,8 +2476,7 @@
}
/* send update on each connected network */
-
- LIST_LOOP(ifp->connected, connected, ifnode)
+ for (ALL_LIST_ELEMENTS (ifp->connected, ifnode, ifnnode, connected))
{
struct prefix_ipv4 *ifaddr;
int done = 0;
@@ -2716,7 +2711,7 @@
{
struct rte *rte;
struct rip_packet rip_packet;
- struct listnode *node;
+ struct listnode *node, *nnode;
memset (&rip_packet, 0, sizeof (rip_packet));
@@ -2740,7 +2735,7 @@
}
/* send request on each connected network */
- LIST_LOOP(ifp->connected, connected, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
{
struct prefix_ipv4 *p;
@@ -3533,9 +3528,8 @@
vty_out (vty, " Interface Send Recv Key-chain%s", VTY_NEWLINE);
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if (ri->enable_network || ri->enable_interface)
@@ -3563,9 +3557,8 @@
{
int found_passive = 0;
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if ((ri->enable_network || ri->enable_interface) && ri->passive)
@@ -3761,13 +3754,10 @@
rip_distribute_update_all (struct prefix_list *notused)
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_distribute_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_distribute_update_interface (ifp);
}
/* ARGSUSED */
void
@@ -3955,13 +3945,10 @@
rip_routemap_update (const char *notused)
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_if_rmap_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_if_rmap_update_interface (ifp);
rip_routemap_update_redistribute ();
}