summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
authorpaul <paul>2005-04-07 07:30:20 +0000
committerpaul <paul>2005-04-07 07:30:20 +0000
commit1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch)
treef5b09d4781de9a9b08839fefb6530e64d2d2ec31 /zebra
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist, and some basic auditing of usage. * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES * HACKING: Add notes about deprecating interfaces and commands. * lib/linklist.h: Add usage comments. Rename getdata macro to listgetdata. Rename nextnode to listnextnode and fix its odd behaviour to be less dangerous. Make listgetdata macro assert node is not null, NULL list entries should be bug condition. ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use with for loop, Suggested by Jim Carlson of Sun. Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the "safety" of previous macro. LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to distinguish from the similarly named functions, and reflect their effect better. Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section with the old defines which were modified above, for backwards compatibility - guarded to prevent Quagga using it.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single scan of the area list, rather than scanning all areas first for INTER_ROUTER and then again for INTER_NETWORK. According to 16.2, the scan should be area specific anyway, and further ospf6d does not seem to implement 16.3 anyway.
Diffstat (limited to 'zebra')
-rw-r--r--zebra/connected.c18
-rw-r--r--zebra/if_ioctl.c6
-rw-r--r--zebra/if_ioctl_solaris.c2
-rw-r--r--zebra/interface.c42
-rw-r--r--zebra/irdp_interface.c13
-rw-r--r--zebra/irdp_main.c15
-rw-r--r--zebra/redistribute.c142
-rw-r--r--zebra/router-id.c30
-rw-r--r--zebra/rtadv.c24
-rw-r--r--zebra/zserv.c19
10 files changed, 132 insertions, 179 deletions
diff --git a/zebra/connected.c b/zebra/connected.c
index 5f581915..3ce59530 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -41,13 +41,10 @@ connected_check_ipv4 (struct interface *ifp, struct prefix *p)
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 @@ connected_check_ipv6 (struct interface *ifp, struct prefix *p)
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 0d7713db..24c4cd74 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -409,13 +409,11 @@ if_get_addr (struct interface *ifp)
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 aa01b073..ae6a9452 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -344,7 +344,7 @@ if_lookup_linklocal (struct interface *ifp)
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 0f294a56..bd31fb40 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -170,7 +170,7 @@ if_subnet_delete (struct interface *ifp, struct connected *ifc)
/* 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 @@ if_subnet_delete (struct interface *ifp, struct connected *ifc)
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 @@ if_delete_update (struct interface *ifp)
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 @@ if_delete_update (struct interface *ifp)
}
next = node->next;
- ifc = getdata (node);
+ ifc = listgetdata (node);
p = ifc->address;
connected_down_ipv4 (ifp, ifc);
@@ -423,10 +422,8 @@ if_up (struct interface *ifp)
/* 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 @@ if_down (struct interface *ifp)
/* 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_dump_vty (struct vty *vty, struct interface *ifp)
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 @@ DEFUN (show_interface, show_interface_cmd,
}
/* 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 @@ DEFUN (show_interface_desc,
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 @@ if_config_write (struct vty *vty)
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_config_write (struct vty *vty)
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 5f913856..dd773402 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -81,7 +81,7 @@ irdp_get_prefix(struct interface *ifp)
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 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
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 @@ void irdp_config_write (struct vty *vty, struct interface *ifp)
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 @@ DEFUN (ip_irdp_address_preference,
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 @@ DEFUN (no_ip_irdp_address_preference,
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 af6bb80b..04f12f18 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -150,7 +150,7 @@ get_pref(struct irdp_interface *irdp, struct prefix *p)
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 @@ int irdp_send_thread(struct thread *t_advert)
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 @@ void irdp_advert_off(struct interface *ifp)
{
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 @@ void irdp_advert_off(struct interface *ifp)
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 process_solicit (struct interface *ifp)
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 949159de..dff6cb54 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -169,71 +169,71 @@ zebra_redistribute (struct zserv *client, int type)
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 @@ zebra_redistribute_default_delete (int command, struct zserv *client,
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 @@ zebra_interface_add_update (struct interface *ifp)
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 @@ void
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 @@ zebra_interface_address_add_update (struct interface *ifp,
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 @@ void
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 @@ zebra_interface_address_delete_update (struct interface *ifp,
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 3052e56a..6194582e 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -52,12 +52,10 @@ router_id_find_node (struct list *l, struct connected *ifc)
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 @@ router_id_get (struct prefix *p)
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 @@ router_id_set (struct prefix *p)
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 @@ router_id_add_address (struct connected *ifc)
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 @@ router_id_del_address (struct connected *ifc)
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 72596563..3e223985 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -166,6 +166,7 @@ rtadv_send_packet (int sock, struct interface *ifp)
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 @@ rtadv_send_packet (int sock, struct interface *ifp)
}
/* 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 @@ rtadv_send_packet (int sock, struct interface *ifp)
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_timer (struct thread *thread)
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 @@ rtadv_prefix_lookup (struct list *rplist, struct prefix *p)
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 @@ rtadv_config_write (struct vty *vty, struct interface *ifp)
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 a34e214a..4eaf6bd3 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -721,18 +721,16 @@ zsend_router_id_update (struct zserv *client, struct prefix *p)
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 @@ zread_interface_add (struct zserv *client, u_short length)
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 @@ DEFUN (show_zebra_client,
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;
}