summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2000-12-05 16:21:00 +0000
committerjlemon <jlemon@FreeBSD.org>2000-12-05 16:21:00 +0000
commita2092162756eff18d1440ac2ccca246dd6e1412e (patch)
treedfc69730e85be86c5faeb42704e4b408d9dfed41 /sys
parent1144f3ac9a6d3b1e4007c2f8252d4f7ac126a3c4 (diff)
downloadFreeBSD-src-a2092162756eff18d1440ac2ccca246dd6e1412e.zip
FreeBSD-src-a2092162756eff18d1440ac2ccca246dd6e1412e.tar.gz
Move the wakeup/signaling of the reader side of the tun device into
a tunstart function, which is called when a packet is sucessfully placed on the queue. This allows us to properly do output byte accounting within the handoff routine.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_tun.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 5cbe111..bc1e2c6 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -65,6 +65,7 @@ static int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *rt));
static int tunifioctl __P((struct ifnet *, u_long, caddr_t));
static int tuninit __P((struct ifnet *));
+static void tunstart __P((struct ifnet *));
static d_open_t tunopen;
static d_close_t tunclose;
@@ -122,6 +123,21 @@ tunattach(dummy)
}
static void
+tunstart(ifp)
+ struct ifnet *ifp;
+{
+ struct tun_softc *tp = ifp->if_softc;
+
+ if (tp->tun_flags & TUN_RWAIT) {
+ tp->tun_flags &= ~TUN_RWAIT;
+ wakeup((caddr_t)tp);
+ }
+ if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio)
+ pgsigio(tp->tun_sigio, SIGIO, 0);
+ selwakeup(&tp->tun_rsel);
+}
+
+static void
tuncreate(dev)
dev_t dev;
{
@@ -141,6 +157,7 @@ tuncreate(dev)
ifp->if_mtu = TUNMTU;
ifp->if_ioctl = tunifioctl;
ifp->if_output = tunoutput;
+ ifp->if_start = tunstart;
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
ifp->if_type = IFT_PPP;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
@@ -402,19 +419,11 @@ tunoutput(ifp, m0, dst, rt)
}
}
- if (! IF_HANDOFF(&ifp->if_snd, m0, NULL)) {
+ if (! IF_HANDOFF(&ifp->if_snd, m0, ifp)) {
ifp->if_collisions++;
return ENOBUFS;
}
ifp->if_opackets++;
-
- if (tp->tun_flags & TUN_RWAIT) {
- tp->tun_flags &= ~TUN_RWAIT;
- wakeup((caddr_t)tp);
- }
- if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio)
- pgsigio(tp->tun_sigio, SIGIO, 0);
- selwakeup(&tp->tun_rsel);
return 0;
}
OpenPOWER on IntegriCloud