diff options
-rw-r--r-- | sys/net/if_tun.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index a0cfcc85016..bc79e9037c5 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.47 2003/05/03 21:15:11 deraadt Exp $ */ +/* $OpenBSD: if_tun.c,v 1.48 2003/06/12 10:49:17 henning Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -450,6 +450,7 @@ tunioctl(dev, cmd, data, flag, p) int unit, s; struct tun_softc *tp; struct tuninfo *tunp; + struct mbuf *m; if ((unit = minor(dev)) >= ntun) return (ENXIO); @@ -511,8 +512,9 @@ tunioctl(dev, cmd, data, flag, p) tp->tun_flags &= ~TUN_ASYNC; break; case FIONREAD: - if (tp->tun_if.if_snd.ifq_head) - *(int *)data = tp->tun_if.if_snd.ifq_head->m_pkthdr.len; + IFQ_POLL(&tp->tun_if.if_snd, m); + if (m != NULL) + *(int *)data = m->m_pkthdr.len; else *(int *)data = 0; break; @@ -748,6 +750,7 @@ tunselect(dev, rw, p) int unit, s; struct tun_softc *tp; struct ifnet *ifp; + struct mbuf *m; if ((unit = minor(dev)) >= ntun) return (ENXIO); @@ -759,7 +762,8 @@ tunselect(dev, rw, p) switch (rw) { case FREAD: - if (ifp->if_snd.ifq_len > 0) { + IFQ_POLL(&ifp->if_snd, m); + if (m != NULL) { splx(s); TUNDEBUG(("%s: tunselect q=%d\n", ifp->if_xname, ifp->if_snd.ifq_len)); |