summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/nd6.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-12-29 18:25:18 +0000
committerjhb <jhb@FreeBSD.org>2011-12-29 18:25:18 +0000
commit7a0151720c2fe467008a6d652b662b6bf34f8f4b (patch)
treea49d597cd77d96cec5272f2d22c60ea00932699a /sys/netinet6/nd6.c
parentf6d4e2f059e27289d1c8365780ea3c7234117776 (diff)
downloadFreeBSD-src-7a0151720c2fe467008a6d652b662b6bf34f8f4b.zip
FreeBSD-src-7a0151720c2fe467008a6d652b662b6bf34f8f4b.tar.gz
Use queue(3) macros instead of home-rolled versions in several places in
the INET6 code. This includes retiring the 'ndpr_next' and 'pfr_next' macros. Submitted by: pluknet (earlier version) Reviewed by: pluknet
Diffstat (limited to 'sys/netinet6/nd6.c')
-rw-r--r--sys/netinet6/nd6.c72
1 files changed, 24 insertions, 48 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 5d6f8c0..1aa437b 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -572,8 +572,8 @@ nd6_timer(void *arg)
{
CURVNET_SET((struct vnet *) arg);
int s;
- struct nd_defrouter *dr;
- struct nd_prefix *pr;
+ struct nd_defrouter *dr, *ndr;
+ struct nd_prefix *pr, *npr;
struct in6_ifaddr *ia6, *nia6;
struct in6_addrlifetime *lt6;
@@ -582,16 +582,9 @@ nd6_timer(void *arg)
/* expire default router list */
s = splnet();
- dr = TAILQ_FIRST(&V_nd_defrouter);
- while (dr) {
- if (dr->expire && dr->expire < time_second) {
- struct nd_defrouter *t;
- t = TAILQ_NEXT(dr, dr_entry);
+ TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) {
+ if (dr->expire && dr->expire < time_second)
defrtrlist_del(dr);
- dr = t;
- } else {
- dr = TAILQ_NEXT(dr, dr_entry);
- }
}
/*
@@ -668,8 +661,7 @@ nd6_timer(void *arg)
}
/* expire prefix list */
- pr = V_nd_prefix.lh_first;
- while (pr) {
+ LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, npr) {
/*
* check prefix lifetime.
* since pltime is just for autoconf, pltime processing for
@@ -677,18 +669,13 @@ nd6_timer(void *arg)
*/
if (pr->ndpr_vltime != ND6_INFINITE_LIFETIME &&
time_second - pr->ndpr_lastupdate > pr->ndpr_vltime) {
- struct nd_prefix *t;
- t = pr->ndpr_next;
/*
* address expiration and prefix expiration are
* separate. NEVER perform in6_purgeaddr here.
*/
-
prelist_remove(pr);
- pr = t;
- } else
- pr = pr->ndpr_next;
+ }
}
splx(s);
CURVNET_RESTORE();
@@ -781,8 +768,7 @@ nd6_purge(struct ifnet *ifp)
* in the routing table, in order to keep additional side effects as
* small as possible.
*/
- for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = ndr) {
- ndr = TAILQ_NEXT(dr, dr_entry);
+ TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) {
if (dr->installed)
continue;
@@ -790,8 +776,7 @@ nd6_purge(struct ifnet *ifp)
defrtrlist_del(dr);
}
- for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = ndr) {
- ndr = TAILQ_NEXT(dr, dr_entry);
+ TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) {
if (!dr->installed)
continue;
@@ -800,8 +785,7 @@ nd6_purge(struct ifnet *ifp)
}
/* Nuke prefix list entries toward ifp */
- for (pr = V_nd_prefix.lh_first; pr; pr = npr) {
- npr = pr->ndpr_next;
+ LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, npr) {
if (pr->ndpr_ifp == ifp) {
/*
* Because if_detach() does *not* release prefixes
@@ -912,7 +896,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp)
* If the address matches one of our on-link prefixes, it should be a
* neighbor.
*/
- for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
+ LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
if (pr->ndpr_ifp != ifp)
continue;
@@ -962,7 +946,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp)
* as on-link, and thus, as a neighbor.
*/
if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV &&
- TAILQ_FIRST(&V_nd_defrouter) == NULL &&
+ TAILQ_EMPTY(&V_nd_defrouter) &&
V_nd6_defifindex == ifp->if_index) {
return (1);
}
@@ -1234,8 +1218,9 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
*/
bzero(drl, sizeof(*drl));
s = splnet();
- dr = TAILQ_FIRST(&V_nd_defrouter);
- while (dr && i < DRLSTSIZ) {
+ TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) {
+ if (i >= DRLSTSIZ)
+ break;
drl->defrouter[i].rtaddr = dr->rtaddr;
in6_clearscope(&drl->defrouter[i].rtaddr);
@@ -1244,7 +1229,6 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
drl->defrouter[i].expire = dr->expire;
drl->defrouter[i].if_index = dr->ifp->if_index;
i++;
- dr = TAILQ_NEXT(dr, dr_entry);
}
splx(s);
break;
@@ -1263,11 +1247,12 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
*/
bzero(oprl, sizeof(*oprl));
s = splnet();
- pr = V_nd_prefix.lh_first;
- while (pr && i < PRLSTSIZ) {
+ LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
struct nd_pfxrouter *pfr;
int j;
+ if (i >= PRLSTSIZ)
+ break;
oprl->prefix[i].prefix = pr->ndpr_prefix.sin6_addr;
oprl->prefix[i].raflags = pr->ndpr_raf;
oprl->prefix[i].prefixlen = pr->ndpr_plen;
@@ -1292,9 +1277,8 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
oprl->prefix[i].expire = maxexpire;
}
- pfr = pr->ndpr_advrtrs.lh_first;
j = 0;
- while (pfr) {
+ LIST_FOREACH(pfr, &pr->ndpr_advrtrs, pfr_entry) {
if (j < DRLSTSIZ) {
#define RTRADDR oprl->prefix[i].advrtr[j]
RTRADDR = pfr->router->rtaddr;
@@ -1302,13 +1286,11 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
#undef RTRADDR
}
j++;
- pfr = pfr->pfr_next;
}
oprl->prefix[i].advrtrs = j;
oprl->prefix[i].origin = PR_ORIG_RA;
i++;
- pr = pr->ndpr_next;
}
splx(s);
@@ -1470,11 +1452,9 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
struct nd_prefix *pr, *next;
s = splnet();
- for (pr = V_nd_prefix.lh_first; pr; pr = next) {
+ LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, next) {
struct in6_ifaddr *ia, *ia_next;
- next = pr->ndpr_next;
-
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
continue; /* XXX */
@@ -1500,8 +1480,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
s = splnet();
defrouter_reset();
- for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; dr = next) {
- next = TAILQ_NEXT(dr, dr_entry);
+ TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, next) {
defrtrlist_del(dr);
}
defrouter_select();
@@ -1824,8 +1803,7 @@ nd6_slowtimo(void *arg)
callout_reset(&V_nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz,
nd6_slowtimo, curvnet);
IFNET_RLOCK_NOSLEEP();
- for (ifp = TAILQ_FIRST(&V_ifnet); ifp;
- ifp = TAILQ_NEXT(ifp, if_list)) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_list) {
nd6if = ND_IFINFO(ifp);
if (nd6if->basereachable && /* already initialized */
(nd6if->recalctm -= ND6_SLOWTIMER_INTERVAL) <= 0) {
@@ -2294,8 +2272,7 @@ nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS)
return EPERM;
error = 0;
- for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
- dr = TAILQ_NEXT(dr, dr_entry)) {
+ TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) {
d = (struct in6_defrouter *)buf;
de = (struct in6_defrouter *)(buf + sizeof(buf));
@@ -2335,7 +2312,7 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS)
return EPERM;
error = 0;
- for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
+ LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
u_short advrtrs;
size_t advance;
struct sockaddr_in6 *sin6, *s6;
@@ -2380,8 +2357,7 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS)
p->flags = pr->ndpr_stateflags;
p->origin = PR_ORIG_RA;
advrtrs = 0;
- for (pfr = pr->ndpr_advrtrs.lh_first; pfr;
- pfr = pfr->pfr_next) {
+ LIST_FOREACH(pfr, &pr->ndpr_advrtrs, pfr_entry) {
if ((void *)&sin6[advrtrs + 1] > (void *)pe) {
advrtrs++;
continue;
OpenPOWER on IntegriCloud