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/zebra/connected.c b/zebra/connected.c
index 5f58191..3ce5953 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -41,13 +41,10 @@
struct connected *ifc;
struct listnode *node;
- for (node = listhead (ifp->connected); node; node = nextnode (node))
- {
- ifc = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
+ if (prefix_same (ifc->address, p))
+ return ifc;
- if (prefix_same (ifc->address, p))
- return ifc;
- }
return NULL;
}
@@ -267,13 +264,10 @@
struct connected *ifc;
struct listnode *node;
- for (node = listhead (ifp->connected); node; node = nextnode (node))
- {
- ifc = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
+ if (prefix_same (ifc->address, p))
+ return ifc;
- if (prefix_same (ifc->address, p))
- return ifc;
- }
return 0;
}
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 0d7713d..24c4cd7 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -409,13 +409,11 @@
static void
interface_info_ioctl ()
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
- LIST_LOOP (iflist, ifp, node)
+ for (ALL_LIST_ELEMENTS (iflist, ifp, node, nnode))
{
- ifp = getdata (node);
-
if_get_index (ifp);
#ifdef SIOCGIFHWADDR
if_get_hwaddr (ifp);
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index aa01b07..ae6a945 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -344,7 +344,7 @@
if (ifp == NULL)
return NULL;
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifc, node))
{
if ((ifc->address->family == AF_INET6) &&
(IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6)))
diff --git a/zebra/interface.c b/zebra/interface.c
index 0f294a5..bd31fb4 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -170,7 +170,7 @@
/* If deleted address is primary, mark subsequent one as such and distribute. */
if (! CHECK_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY))
{
- ifc = (struct connected *) addr_list->head->data;
+ ifc = listgetdata (listhead (addr_list));
zebra_interface_address_delete_update (ifp, ifc);
UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY);
zebra_interface_address_add_update (ifp, ifc);
@@ -192,14 +192,13 @@
void
if_addr_wakeup (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct connected *ifc;
struct prefix *p;
int ret;
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
{
- ifc = getdata (node);
p = ifc->address;
if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)
@@ -334,7 +333,7 @@
last = NULL;
while ((node = (last ? last->next : listhead (ifp->connected))))
{
- ifc = getdata (node);
+ ifc = listgetdata (node);
p = ifc->address;
if (p->family == AF_INET)
@@ -354,7 +353,7 @@
}
next = node->next;
- ifc = getdata (node);
+ ifc = listgetdata (node);
p = ifc->address;
connected_down_ipv4 (ifp, ifc);
@@ -423,10 +422,8 @@
/* Install connected routes to the kernel. */
if (ifp->connected)
{
- for (node = listhead (ifp->connected); node; node = next)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
{
- next = node->next;
- ifc = getdata (node);
p = ifc->address;
if (p->family == AF_INET)
@@ -458,10 +455,8 @@
/* Delete connected routes from the kernel. */
if (ifp->connected)
{
- for (node = listhead (ifp->connected); node; node = next)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
{
- next = node->next;
- ifc = getdata (node);
p = ifc->address;
if (p->family == AF_INET)
@@ -727,16 +722,12 @@
if (! rn->info)
continue;
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- {
- connected = getdata (node);
- connected_dump_vty (vty, connected);
- }
+ for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, connected))
+ connected_dump_vty (vty, connected);
}
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
{
- connected = getdata (node);
if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) &&
(connected->address->family == AF_INET6))
connected_dump_vty (vty, connected);
@@ -902,8 +893,8 @@
}
/* All interface print. */
- for (node = listhead (iflist); node; nextnode (node))
- if_dump_vty (vty, getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ if_dump_vty (vty, ifp);
return CMD_SUCCESS;
}
@@ -919,10 +910,9 @@
struct interface *ifp;
vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE);
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
int len;
- ifp = getdata (node);
len = vty_out (vty, "%s", ifp->name);
vty_out (vty, "%*s", (16 - len), " ");
@@ -1514,14 +1504,13 @@
struct interface *ifp;
char buf[BUFSIZ];
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
struct zebra_if *if_data;
struct listnode *addrnode;
struct connected *ifc;
struct prefix *p;
- ifp = getdata (node);
if_data = ifp->info;
vty_out (vty, "interface %s%s", ifp->name,
@@ -1539,9 +1528,8 @@
if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))
vty_out(vty, " link-detect%s", VTY_NEWLINE);
- for (addrnode = listhead (ifp->connected); addrnode; nextnode (addrnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc))
{
- ifc = getdata (addrnode);
if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
{
p = ifc->address;
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index 5f91385..dd77340 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -81,7 +81,7 @@
struct connected *ifc;
if (ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
return ifc->address;
return NULL;
@@ -235,7 +235,7 @@
seed = 0;
if( ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
seed = ifc->address->u.prefix4.s_addr;
break;
@@ -355,7 +355,7 @@
vty_out (vty, " ip irdp preference %ld%s",
irdp->Preference, VTY_NEWLINE);
- LIST_LOOP (irdp->AdvPrefList, adv, node)
+ for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
vty_out (vty, " ip irdp address %s preference %d%s",
inet_2a(adv->ip.s_addr, b1),
adv->pref,
@@ -610,7 +610,7 @@
pref = atoi(argv[1]);
- LIST_LOOP (irdp->AdvPrefList, adv, node)
+ for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
if(adv->ip.s_addr == ip.s_addr)
return CMD_SUCCESS;
@@ -656,11 +656,8 @@
pref = atoi(argv[1]);
- for (node = listhead (irdp->AdvPrefList); node; node = nnode)
+ for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv))
{
- nnode = node->next;
- adv = getdata (node);
-
if(adv->ip.s_addr == ip.s_addr )
{
listnode_delete(irdp->AdvPrefList, adv);
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index af6bb80..04f12f1 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -150,7 +150,7 @@
if( irdp->AdvPrefList == NULL )
return irdp->Preference;
- LIST_LOOP (irdp->AdvPrefList, adv, node)
+ for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
if( p->u.prefix4.s_addr == adv->ip.s_addr )
return adv->pref;
@@ -234,13 +234,13 @@
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
struct prefix *p;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct connected *ifc;
irdp->flags &= ~IF_SOLICIT;
if(ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
{
p = ifc->address;
irdp_advertisement(ifp, p);
@@ -266,7 +266,7 @@
{
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
- struct listnode *node;
+ struct listnode *node, *nnode;
int i;
struct connected *ifc;
struct prefix *p;
@@ -275,7 +275,7 @@
irdp->t_advertise = NULL;
if(ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
{
p = ifc->address;
@@ -319,16 +319,15 @@
void irdp_finish()
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
zlog_info("IRDP: Received shutdown notification.");
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
{
- ifp = getdata(node);
zi = ifp->info;
if (!zi)
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 949159d..dff6cb5 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -169,71 +169,71 @@
void
redistribute_add (struct prefix *p, struct rib *rib)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- {
- if (is_default (p))
- {
- if (client->redist_default || client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ {
+ if (is_default (p))
+ {
+ if (client->redist_default || client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
#endif /* HAVE_IPV6 */
- }
- }
- else if (client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ }
+ }
+ else if (client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
#endif /* HAVE_IPV6 */
- }
- }
+ }
+ }
}
void
redistribute_delete (struct prefix *p, struct rib *rib)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
/* Add DISTANCE_INFINITY check. */
if (rib->distance == DISTANCE_INFINITY)
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- {
- if (is_default (p))
- {
- if (client->redist_default || client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ {
+ if (is_default (p))
+ {
+ if (client->redist_default || client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p,
+ rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
-#endif /* HAVE_IPV6 */
- }
- }
- else if (client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p,
+ rib);
+#endif /* HAVE_IPV6 */
+ }
+ }
+ else if (client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
-#endif /* HAVE_IPV6 */
- }
- }
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
+#endif /* HAVE_IPV6 */
+ }
+ }
}
void
@@ -306,46 +306,43 @@
void
zebra_interface_up_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp);
}
/* Interface down information. */
void
zebra_interface_down_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp);
}
/* Interface information update. */
void
zebra_interface_add_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADD %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo)
- zsend_interface_add (client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo)
+ zsend_interface_add (client, ifp);
}
/*
@@ -357,16 +354,15 @@
void
zebra_interface_delete_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo)
- zsend_interface_delete (client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo)
+ zsend_interface_delete (client, ifp);
}
#endif /* defined(RTM_IFANNOUNCE) || defined(HAVE_NETLINK) */
@@ -375,7 +371,7 @@
zebra_interface_address_add_update (struct interface *ifp,
struct connected *ifc)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
char buf[BUFSIZ];
@@ -390,10 +386,9 @@
router_id_add_address(ifc);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc);
}
/* Interface address deletion. */
@@ -401,7 +396,7 @@
zebra_interface_address_delete_update (struct interface *ifp,
struct connected *ifc)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
char buf[BUFSIZ];
@@ -416,8 +411,7 @@
router_id_del_address(ifc);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc);
}
diff --git a/zebra/router-id.c b/zebra/router-id.c
index 3052e56..6194582 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -52,12 +52,10 @@
struct listnode *node;
struct connected *c;
- for (node = l->head; node; node = node->next)
- {
- c = (struct connected *) getdata (node);
- if (prefix_same (ifc->address, c->address))
- return c;
- }
+ for (ALL_LIST_ELEMENTS_RO (l, node, c))
+ if (prefix_same (ifc->address, c->address))
+ return c;
+
return NULL;
}
@@ -94,13 +92,13 @@
else if (!list_isempty (&rid_lo_sorted_list))
{
node = listtail (&rid_lo_sorted_list);
- c = getdata (node);
+ c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
else if (!list_isempty (&rid_all_sorted_list))
{
node = listtail (&rid_all_sorted_list);
- c = getdata (node);
+ c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
}
@@ -115,9 +113,9 @@
rid_user_assigned.u.prefix4.s_addr = p->u.prefix4.s_addr;
router_id_get (&p2);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &p2);
+
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &p2);
}
void
@@ -148,9 +146,8 @@
if (prefix_same (&before, &after))
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &after);
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &after);
}
void
@@ -182,9 +179,8 @@
if (prefix_same (&before, &after))
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &after);
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &after);
}
void
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 7259656..3e22398 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -166,6 +166,7 @@
int ret;
int len = 0;
struct zebra_if *zif;
+ struct rtadv_prefix *rprefix;
u_char all_nodes_addr[] = {0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
struct listnode *node;
@@ -245,12 +246,9 @@
}
/* Fill in prefix. */
- for (node = listhead (zif->rtadv.AdvPrefixList); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix))
{
struct nd_opt_prefix_info *pinfo;
- struct rtadv_prefix *rprefix;
-
- rprefix = getdata (node);
pinfo = (struct nd_opt_prefix_info *) (buf + len);
@@ -338,7 +336,7 @@
int
rtadv_timer (struct thread *thread)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zif;
int period;
@@ -355,10 +353,8 @@
rtadv_event (RTADV_TIMER_MSEC, 10 /* 10 ms */);
}
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
{
- ifp = getdata (node);
-
if (if_is_loopback (ifp))
continue;
@@ -553,12 +549,9 @@
struct listnode *node;
struct rtadv_prefix *rprefix;
- for (node = listhead (rplist); node; node = nextnode (node))
- {
- rprefix = getdata (node);
- if (prefix_same (&rprefix->prefix, p))
- return rprefix;
- }
+ for (ALL_LIST_ELEMENTS_RO (rplist, node, rprefix))
+ if (prefix_same (&rprefix->prefix, p))
+ return rprefix;
return NULL;
}
@@ -1426,9 +1419,8 @@
if (zif->rtadv.AdvOtherConfigFlag)
vty_out (vty, " ipv6 nd other-config-flag%s", VTY_NEWLINE);
- for (node = listhead(zif->rtadv.AdvPrefixList); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix))
{
- rprefix = getdata (node);
vty_out (vty, " ipv6 nd prefix %s/%d",
inet_ntop (AF_INET6, &rprefix->prefix.u.prefix6,
(char *) buf, INET6_ADDRSTRLEN),
diff --git a/zebra/zserv.c b/zebra/zserv.c
index a34e214..4eaf6bd 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -721,18 +721,16 @@
static int
zread_interface_add (struct zserv *client, u_short length)
{
- struct listnode *ifnode;
- struct listnode *cnode;
+ struct listnode *ifnode, *ifnnode;
+ struct listnode *cnode, *cnnode;
struct interface *ifp;
struct connected *c;
/* Interface information is needed. */
client->ifinfo = 1;
- for (ifnode = listhead (iflist); ifnode; ifnode = nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS (iflist, ifnode, ifnnode, ifp))
{
- ifp = getdata (ifnode);
-
/* Skip pseudo interface. */
if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
continue;
@@ -740,9 +738,8 @@
if (zsend_interface_add (client, ifp) < 0)
return -1;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, c))
{
- c = getdata (cnode);
if (CHECK_FLAG (c->conf, ZEBRA_IFC_REAL) &&
(zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client,
ifp, c) < 0))
@@ -1566,11 +1563,9 @@
struct listnode *node;
struct zserv *client;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- {
- client = getdata (node);
- vty_out (vty, "Client fd %d%s", client->sock, VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ vty_out (vty, "Client fd %d%s", client->sock, VTY_NEWLINE);
+
return CMD_SUCCESS;
}