summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/if_ether.h12
-rw-r--r--sys/netinet/in.c37
-rw-r--r--sys/netinet/in_pcb.c29
-rw-r--r--sys/netinet/in_var.h31
-rw-r--r--sys/netinet/ip_icmp.c4
-rw-r--r--sys/netinet/ip_input.c48
-rw-r--r--sys/netinet/ip_ipip.c8
-rw-r--r--sys/netinet/ip_output.c6
-rw-r--r--sys/netinet/raw_ip.c6
9 files changed, 89 insertions, 92 deletions
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h
index 321e3252e03..83e7d110312 100644
--- a/sys/netinet/if_ether.h
+++ b/sys/netinet/if_ether.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.h,v 1.35 2005/03/28 06:19:58 tedu Exp $ */
+/* $OpenBSD: if_ether.h,v 1.36 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
@@ -243,11 +243,11 @@ struct ether_multistep {
/* struct arpcom *ac; */ \
/* struct ether_multi *enm; */ \
{ \
- for ((enm) = (ac)->ac_multiaddrs.lh_first; \
- (enm) != NULL && \
+ for ((enm) = LIST_FIRST(&(ac)->ac_multiaddrs); \
+ (enm) != LIST_END(&(ac)->ac_multiaddrs) && \
(bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \
bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
- (enm) = (enm)->enm_list.le_next); \
+ (enm) = LIST_NEXT((enm), enm_list)); \
}
/*
@@ -262,7 +262,7 @@ struct ether_multistep {
/* struct ether_multi *enm; */ \
{ \
if (((enm) = (step).e_enm) != NULL) \
- (step).e_enm = (enm)->enm_list.le_next; \
+ (step).e_enm = LIST_NEXT((enm), enm_list); \
}
#define ETHER_FIRST_MULTI(step, ac, enm) \
@@ -270,7 +270,7 @@ struct ether_multistep {
/* struct arpcom *ac; */ \
/* struct ether_multi *enm; */ \
{ \
- (step).e_enm = (ac)->ac_multiaddrs.lh_first; \
+ (step).e_enm = LIST_FIRST(&(ac)->ac_multiaddrs); \
ETHER_NEXT_MULTI((step), (enm)); \
}
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index ed48a712707..f2d13390bd9 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.43 2006/03/04 22:40:16 brad Exp $ */
+/* $OpenBSD: in.c,v 1.44 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -114,11 +114,11 @@ in_localaddr(in)
struct in_ifaddr *ia;
if (subnetsarelocal) {
- for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if ((in.s_addr & ia->ia_netmask) == ia->ia_net)
return (1);
} else {
- for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if ((in.s_addr & ia->ia_subnetmask) == ia->ia_subnet)
return (1);
}
@@ -240,7 +240,7 @@ in_control(so, cmd, data, ifp)
* Find address for this interface, if it exists.
*/
if (ifp)
- for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if (ia->ia_ifp == ifp)
break;
@@ -249,12 +249,13 @@ in_control(so, cmd, data, ifp)
case SIOCAIFADDR:
case SIOCDIFADDR:
if (ifra->ifra_addr.sin_family == AF_INET)
- for (; ia != 0; ia = ia->ia_list.tqe_next) {
- if (ia->ia_ifp == ifp &&
- ia->ia_addr.sin_addr.s_addr ==
- ifra->ifra_addr.sin_addr.s_addr)
- break;
- }
+ for (; ia != TAILQ_END(&in_ifaddr);
+ ia = TAILQ_NEXT(ia, ia_list)) {
+ if (ia->ia_ifp == ifp &&
+ ia->ia_addr.sin_addr.s_addr ==
+ ifra->ifra_addr.sin_addr.s_addr)
+ break;
+ }
if (cmd == SIOCDIFADDR && ia == 0)
return (EADDRNOTAVAIL);
/* FALLTHROUGH */
@@ -307,7 +308,8 @@ in_control(so, cmd, data, ifp)
if (ia && satosin(&ifr->ifr_addr)->sin_addr.s_addr) {
struct in_ifaddr *ia2;
- for (ia2 = ia; ia2; ia2 = ia2->ia_list.tqe_next) {
+ for (ia2 = ia; ia2 != TAILQ_END(&in_ifaddr);
+ ia2 = TAILQ_NEXT(ia2, ia_list)) {
if (ia2->ia_ifp == ifp &&
ia2->ia_addr.sin_addr.s_addr ==
satosin(&ifr->ifr_addr)->sin_addr.s_addr)
@@ -594,7 +596,7 @@ in_lifaddr_ioctl(so, cmd, data, ifp)
}
}
- for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) {
+ TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
if (!cmp)
@@ -833,7 +835,7 @@ in_scrubprefix(target)
prefix.s_addr &= mask.s_addr;
}
- for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if (rtinitflags(ia))
p = ia->ia_dstaddr.sin_addr;
else {
@@ -886,11 +888,11 @@ in_broadcast(in, ifp)
return 1;
if (ifp == NULL) {
- if_first = ifnet.tqh_first;
+ if_first = TAILQ_FIRST(&ifnet);
if_target = 0;
} else {
if_first = ifp;
- if_target = ifp->if_list.tqe_next;
+ if_target = TAILQ_NEXT(ifp, if_list);
}
#define ia (ifatoia(ifa))
@@ -899,11 +901,10 @@ in_broadcast(in, ifp)
* with a broadcast address.
* If ifp is NULL, check against all the interfaces.
*/
- for (ifn = if_first; ifn != if_target; ifn = ifn->if_list.tqe_next) {
+ for (ifn = if_first; ifn != if_target; ifn = TAILQ_NEXT(ifn, if_list)) {
if ((ifn->if_flags & IFF_BROADCAST) == 0)
continue;
- for (ifa = ifn->if_addrlist.tqh_first; ifa;
- ifa = ifa->ifa_list.tqe_next)
+ TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list)
if (ifa->ifa_addr->sa_family == AF_INET &&
in.s_addr != ia->ia_addr.sin_addr.s_addr &&
(in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 974f0442e0f..1dc2af9749e 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.84 2005/06/24 07:57:24 markus Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.85 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -247,7 +247,7 @@ in_pcbbind(v, nam)
return in6_pcbbind(inp, nam);
#endif /* INET6 */
- if (in_ifaddr.tqh_first == 0)
+ if (TAILQ_EMPTY(&in_ifaddr))
return (EADDRNOTAVAIL);
if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY)
return (EINVAL);
@@ -399,7 +399,7 @@ in_pcbconnect(v, nam)
return (EAFNOSUPPORT);
if (sin->sin_port == 0)
return (EADDRNOTAVAIL);
- if (in_ifaddr.tqh_first != 0) {
+ if (!TAILQ_EMPTY(&in_ifaddr)) {
/*
* If the destination address is INADDR_ANY,
* use the primary local address.
@@ -408,10 +408,10 @@ in_pcbconnect(v, nam)
* choose the broadcast address for that interface.
*/
if (sin->sin_addr.s_addr == INADDR_ANY)
- sin->sin_addr = in_ifaddr.tqh_first->ia_addr.sin_addr;
+ sin->sin_addr = TAILQ_FIRST(&in_ifaddr)->ia_addr.sin_addr;
else if (sin->sin_addr.s_addr == INADDR_BROADCAST &&
- (in_ifaddr.tqh_first->ia_ifp->if_flags & IFF_BROADCAST))
- sin->sin_addr = in_ifaddr.tqh_first->ia_broadaddr.sin_addr;
+ (TAILQ_FIRST(&in_ifaddr)->ia_ifp->if_flags & IFF_BROADCAST))
+ sin->sin_addr = TAILQ_FIRST(&in_ifaddr)->ia_broadaddr.sin_addr;
}
if (inp->inp_laddr.s_addr == INADDR_ANY) {
int error;
@@ -847,7 +847,7 @@ in_selectsrc(sin, ro, soopts, mopts, errorp)
ia = ifatoia(ifa_ifwithnet(sintosa(sin)));
sin->sin_port = fport;
if (ia == 0)
- ia = in_ifaddr.tqh_first;
+ ia = TAILQ_FIRST(&in_ifaddr);
if (ia == 0) {
*errorp = EADDRNOTAVAIL;
return NULL;
@@ -865,8 +865,7 @@ in_selectsrc(sin, ro, soopts, mopts, errorp)
imo = mopts;
if (imo->imo_multicast_ifp != NULL) {
ifp = imo->imo_multicast_ifp;
- for (ia = in_ifaddr.tqh_first; ia != 0;
- ia = ia->ia_list.tqe_next)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if (ia->ia_ifp == ifp)
break;
if (ia == 0) {
@@ -929,7 +928,7 @@ in_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg)
u_int16_t fport = fport_arg, lport = lport_arg;
head = INPCBHASH(table, &faddr, fport, &laddr, lport);
- for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
+ LIST_FOREACH(inp, head, inp_hash) {
#ifdef INET6
if (inp->inp_flags & INP_IPV6)
continue; /*XXX*/
@@ -943,7 +942,7 @@ in_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg)
* repeated accesses are quicker. This is analogous to
* the historic single-entry PCB cache.
*/
- if (inp != head->lh_first) {
+ if (inp != LIST_FIRST(head)) {
LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash);
}
@@ -972,7 +971,7 @@ in6_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg)
u_int16_t fport = fport_arg, lport = lport_arg;
head = IN6PCBHASH(table, faddr, fport, laddr, lport);
- for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
+ LIST_FOREACH(inp, head, inp_hash) {
if (!(inp->inp_flags & INP_IPV6))
continue;
if (IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, faddr) &&
@@ -983,7 +982,7 @@ in6_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg)
* repeated accesses are quicker. This is analogous to
* the historic single-entry PCB cache.
*/
- if (inp != head->lh_first) {
+ if (inp != LIST_FIRST(head)) {
LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash);
}
@@ -1063,7 +1062,7 @@ in_pcblookup_listen(table, laddr, lport_arg, reverse)
* repeated accesses are quicker. This is analogous to
* the historic single-entry PCB cache.
*/
- if (inp != NULL && inp != head->lh_first) {
+ if (inp != NULL && inp != LIST_FIRST(head)) {
LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash);
}
@@ -1122,7 +1121,7 @@ in6_pcblookup_listen(table, laddr, lport_arg, reverse)
* repeated accesses are quicker. This is analogous to
* the historic single-entry PCB cache.
*/
- if (inp != NULL && inp != head->lh_first) {
+ if (inp != NULL && inp != LIST_FIRST(head)) {
LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash);
}
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index 95aa7c27f9c..083a8e946a3 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_var.h,v 1.8 2005/01/15 09:09:27 pascoe Exp $ */
+/* $OpenBSD: in_var.h,v 1.9 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */
/*
@@ -95,9 +95,9 @@ void in_socktrim(struct sockaddr_in *);
{ \
struct in_ifaddr *ia; \
\
- for (ia = in_ifaddr.tqh_first; \
- ia != NULL && ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \
- ia = ia->ia_list.tqe_next) \
+ for (ia = TAILQ_FIRST(&in_ifaddr); ia != TAILQ_END(&in_ifaddr) && \
+ ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \
+ ia = TAILQ_NEXT(ia, ia_list)) \
continue; \
(ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
}
@@ -110,9 +110,9 @@ void in_socktrim(struct sockaddr_in *);
/* struct ifnet *ifp; */ \
/* struct in_ifaddr *ia; */ \
{ \
- for ((ia) = in_ifaddr.tqh_first; \
- (ia) != NULL && (ia)->ia_ifp != (ifp); \
- (ia) = (ia)->ia_list.tqe_next) \
+ for ((ia) = TAILQ_FIRST(&in_ifaddr); \
+ (ia) != TAILQ_END(&in_ifaddr) && (ia)->ia_ifp != (ifp); \
+ (ia) = TAILQ_NEXT((ia), ia_list)) \
continue; \
}
#endif
@@ -169,9 +169,10 @@ struct in_multistep {
if (ia == NULL) \
(inm) = NULL; \
else \
- for ((inm) = ia->ia_multiaddrs.lh_first; \
- (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \
- (inm) = inm->inm_list.le_next) \
+ for ((inm) = LIST_FIRST(&ia->ia_multiaddrs); \
+ (inm) != LIST_END(&ia->ia_multiaddrs) && \
+ (inm)->inm_addr.s_addr != (addr).s_addr; \
+ (inm) = LIST_NEXT(inm, inm_list)) \
continue; \
}
@@ -187,13 +188,13 @@ struct in_multistep {
/* struct in_multi *inm; */ \
{ \
if (((inm) = (step).i_inm) != NULL) \
- (step).i_inm = (inm)->inm_list.le_next; \
+ (step).i_inm = LIST_NEXT((inm), inm_list); \
else \
while ((step).i_ia != NULL) { \
- (inm) = (step).i_ia->ia_multiaddrs.lh_first; \
- (step).i_ia = (step).i_ia->ia_list.tqe_next; \
+ (inm) = LIST_FIRST(&(step).i_ia->ia_multiaddrs); \
+ (step).i_ia = TAILQ_NEXT((step).i_ia, ia_list); \
if ((inm) != NULL) { \
- (step).i_inm = (inm)->inm_list.le_next; \
+ (step).i_inm = LIST_NEXT((inm), inm_list); \
break; \
} \
} \
@@ -203,7 +204,7 @@ struct in_multistep {
/* struct in_multistep step; */ \
/* struct in_multi *inm; */ \
{ \
- (step).i_ia = in_ifaddr.tqh_first; \
+ (step).i_ia = TAILQ_FIRST(&in_ifaddr); \
(step).i_inm = NULL; \
IN_NEXT_MULTI((step), (inm)); \
}
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 69ffef86641..b40fa9adeba 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.69 2005/10/17 08:43:34 henning Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.70 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -631,7 +631,7 @@ icmp_reflect(struct mbuf *m)
* use dst as the src for the reply. For broadcast, use
* the address which corresponds to the incoming interface.
*/
- for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if (t.s_addr == ia->ia_addr.sin_addr.s_addr)
break;
if ((ia->ia_ifp->if_flags & IFF_BROADCAST) &&
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index e77bee09577..83d63334ad9 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.137 2006/03/04 22:40:16 brad Exp $ */
+/* $OpenBSD: ip_input.c,v 1.138 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -287,7 +287,7 @@ ipv4_input(m)
* If no IP addresses have been set yet but the interfaces
* are receiving, can't do anything with incoming packets yet.
*/
- if (in_ifaddr.tqh_first == 0)
+ if (TAILQ_EMPTY(&in_ifaddr))
goto bad;
ipstat.ips_total++;
if (m->m_len < sizeof (struct ip) &&
@@ -521,7 +521,7 @@ ours:
* of this datagram.
*/
ipq_lock();
- for (fp = ipq.lh_first; fp != NULL; fp = fp->ipq_q.le_next)
+ LIST_FOREACH(fp, &ipq, ipq_q)
if (ip->ip_id == fp->ipq_id &&
ip->ip_src.s_addr == fp->ipq_src.s_addr &&
ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
@@ -751,12 +751,12 @@ ip_reass(ipqe, fp)
* drop if CE and not-ECT are mixed for the same packet.
*/
ecn = ipqe->ipqe_ip->ip_tos & IPTOS_ECN_MASK;
- ecn0 = fp->ipq_fragq.lh_first->ipqe_ip->ip_tos & IPTOS_ECN_MASK;
+ ecn0 = LIST_FIRST(&fp->ipq_fragq)->ipqe_ip->ip_tos & IPTOS_ECN_MASK;
if (ecn == IPTOS_ECN_CE) {
if (ecn0 == IPTOS_ECN_NOTECT)
goto dropfrag;
if (ecn0 != IPTOS_ECN_CE)
- fp->ipq_fragq.lh_first->ipqe_ip->ip_tos |= IPTOS_ECN_CE;
+ LIST_FIRST(&fp->ipq_fragq)->ipqe_ip->ip_tos |= IPTOS_ECN_CE;
}
if (ecn == IPTOS_ECN_NOTECT && ecn0 != IPTOS_ECN_NOTECT)
goto dropfrag;
@@ -764,8 +764,8 @@ ip_reass(ipqe, fp)
/*
* Find a segment which begins after this one does.
*/
- for (p = NULL, q = fp->ipq_fragq.lh_first; q != NULL;
- p = q, q = q->ipqe_q.le_next)
+ for (p = NULL, q = LIST_FIRST(&fp->ipq_fragq);
+ q != LIST_END(&fp->ipq_fragq); p = q, q = LIST_NEXT(q, ipqe_q))
if (ntohs(q->ipqe_ip->ip_off) > ntohs(ipqe->ipqe_ip->ip_off))
break;
@@ -805,7 +805,7 @@ ip_reass(ipqe, fp)
m_adj(q->ipqe_m, i);
break;
}
- nq = q->ipqe_q.le_next;
+ nq = LIST_NEXT(q, ipqe_q);
m_freem(q->ipqe_m);
LIST_REMOVE(q, ipqe_q);
pool_put(&ipqent_pool, q);
@@ -823,8 +823,8 @@ insert:
LIST_INSERT_AFTER(p, ipqe, ipqe_q);
}
next = 0;
- for (p = NULL, q = fp->ipq_fragq.lh_first; q != NULL;
- p = q, q = q->ipqe_q.le_next) {
+ for (p = NULL, q = LIST_FIRST(&fp->ipq_fragq);
+ q != LIST_END(&fp->ipq_fragq); p = q, q = LIST_NEXT(q, ipqe_q)) {
if (ntohs(q->ipqe_ip->ip_off) != next)
return (0);
next += ntohs(q->ipqe_ip->ip_len);
@@ -836,7 +836,7 @@ insert:
* Reassembly is complete. Check for a bogus message size and
* concatenate fragments.
*/
- q = fp->ipq_fragq.lh_first;
+ q = LIST_FIRST(&fp->ipq_fragq);
ip = q->ipqe_ip;
if ((next + (ip->ip_hl << 2)) > IP_MAXPACKET) {
ipstat.ips_toolong++;
@@ -847,12 +847,12 @@ insert:
t = m->m_next;
m->m_next = 0;
m_cat(m, t);
- nq = q->ipqe_q.le_next;
+ nq = LIST_NEXT(q, ipqe_q);
pool_put(&ipqent_pool, q);
ip_frags--;
for (q = nq; q != NULL; q = nq) {
t = q->ipqe_m;
- nq = q->ipqe_q.le_next;
+ nq = LIST_NEXT(q, ipqe_q);
pool_put(&ipqent_pool, q);
ip_frags--;
m_cat(m, t);
@@ -898,8 +898,9 @@ ip_freef(fp)
{
struct ipqent *q, *p;
- for (q = fp->ipq_fragq.lh_first; q != NULL; q = p) {
- p = q->ipqe_q.le_next;
+ for (q = LIST_FIRST(&fp->ipq_fragq); q != LIST_END(&fp->ipq_fragq);
+ q = p) {
+ p = LIST_NEXT(q, ipqe_q);
m_freem(q->ipqe_m);
LIST_REMOVE(q, ipqe_q);
pool_put(&ipqent_pool, q);
@@ -921,8 +922,8 @@ ip_slowtimo()
int s = splsoftnet();
ipq_lock();
- for (fp = ipq.lh_first; fp != NULL; fp = nfp) {
- nfp = fp->ipq_q.le_next;
+ for (fp = LIST_FIRST(&ipq); fp != LIST_END(&ipq); fp = nfp) {
+ nfp = LIST_NEXT(fp, ipq_q);
if (--fp->ipq_ttl == 0) {
ipstat.ips_fragtimeout++;
ip_freef(fp);
@@ -945,9 +946,9 @@ ip_drain()
if (ipq_lock_try() == 0)
return;
- while (ipq.lh_first != NULL) {
+ while (!LIST_EMPTY(&ipq)) {
ipstat.ips_fragdropped++;
- ip_freef(ipq.lh_first);
+ ip_freef(LIST_FIRST(&ipq));
}
ipq_unlock();
}
@@ -961,9 +962,9 @@ ip_flush()
int max = 50;
/* ipq already locked */
- while (ipq.lh_first != NULL && ip_frags > ip_maxqueue * 3 / 4 && --max) {
+ while (!LIST_EMPTY(&ipq) && ip_frags > ip_maxqueue * 3 / 4 && --max) {
ipstat.ips_fragdropped++;
- ip_freef(ipq.lh_first);
+ ip_freef(LIST_FIRST(&ipq));
}
}
@@ -1260,9 +1261,8 @@ ip_weadvertise(addr)
return 0;
}
- for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
- for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
- ifa = ifa->ifa_list.tqe_next) {
+ TAILQ_FOREACH(ifp, &ifnet, if_list)
+ TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != rt->rt_gateway->sa_family)
continue;
diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c
index 9b6fd0c5615..01976eeed4c 100644
--- a/sys/netinet/ip_ipip.c
+++ b/sys/netinet/ip_ipip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipip.c,v 1.34 2006/03/04 22:40:16 brad Exp $ */
+/* $OpenBSD: ip_ipip.c,v 1.35 2006/03/05 21:48:56 miod Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -290,10 +290,8 @@ ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
if ((m->m_pkthdr.rcvif == NULL ||
!(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK)) &&
ipip_allow != 2) {
- for (ifp = ifnet.tqh_first; ifp != 0;
- ifp = ifp->if_list.tqe_next) {
- for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
- ifa = ifa->ifa_list.tqe_next) {
+ TAILQ_FOREACH(ifp, &ifnet, if_list) {
+ TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
#ifdef INET
if (ipo) {
if (ifa->ifa_addr->sa_family !=
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 5582cf9a09a..a811e011339 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.175 2006/03/05 02:29:46 brad Exp $ */
+/* $OpenBSD: ip_output.c,v 1.176 2006/03/05 21:48:56 miod Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -459,9 +459,7 @@ ip_output(struct mbuf *m0, ...)
if (ip->ip_src.s_addr == INADDR_ANY) {
struct in_ifaddr *ia;
- for (ia = in_ifaddr.tqh_first;
- ia;
- ia = ia->ia_list.tqe_next)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if (ia->ia_ifp == ifp) {
ip->ip_src = ia->ia_addr.sin_addr;
break;
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 5791bc7f7ec..a14519aa345 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.37 2005/05/27 04:55:28 mcbride Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.38 2006/03/05 21:48:57 miod Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -387,7 +387,7 @@ rip_usrreq(so, req, m, nam, control)
error = EINVAL;
break;
}
- if ((ifnet.tqh_first == 0) ||
+ if ((TAILQ_EMPTY(&ifnet)) ||
((addr->sin_family != AF_INET) &&
(addr->sin_family != AF_IMPLINK)) ||
(addr->sin_addr.s_addr &&
@@ -406,7 +406,7 @@ rip_usrreq(so, req, m, nam, control)
error = EINVAL;
break;
}
- if (ifnet.tqh_first == 0) {
+ if (TAILQ_EMPTY(&ifnet)) {
error = EADDRNOTAVAIL;
break;
}