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/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 176e447..0c0c8c0 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -46,16 +46,16 @@
bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
{
struct prefix router_id;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
zebra_router_id_update_read(zclient->ibuf,&router_id);
router_id_zebra = router_id.u.prefix4;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
if (!bgp->router_id_static.s_addr)
- bgp_router_id_set (bgp, &router_id.u.prefix4);
+ bgp_router_id_set (bgp, &router_id.u.prefix4);
}
return 0;
@@ -92,7 +92,7 @@
struct stream *s;
struct interface *ifp;
struct connected *c;
- struct listnode *node;
+ struct listnode *node, *nnode;
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
@@ -100,11 +100,8 @@
if (! ifp)
return 0;
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- c = getdata (node);
- bgp_connected_add (c);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
+ bgp_connected_add (c);
return 0;
}
@@ -115,32 +112,29 @@
struct stream *s;
struct interface *ifp;
struct connected *c;
- struct listnode *node;
+ struct listnode *node, *nnode;
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
if (! ifp)
return 0;
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- c = getdata (node);
- bgp_connected_delete (c);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
+ bgp_connected_delete (c);
/* Fast external-failover (Currently IPv4 only) */
{
- struct listnode *nn, *nm;
+ struct listnode *mnode;
struct bgp *bgp;
struct peer *peer;
struct interface *peer_if;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS_RO (bm->bgp, mnode, bgp))
{
if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER))
continue;
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->ttl != 1)
continue;
@@ -319,13 +313,10 @@
p.prefix = *addr;
p.prefixlen = IPV4_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET)
@@ -345,13 +336,10 @@
struct connected *connected;
struct prefix *cp;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET)
@@ -377,13 +365,10 @@
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -403,13 +388,10 @@
struct connected *connected;
struct prefix *cp;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -427,9 +409,8 @@
struct connected *connected;
struct prefix *cp;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -449,9 +430,8 @@
struct connected *connected;
struct prefix *cp;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -591,15 +571,12 @@
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
struct prefix *cp;
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)