1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

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.
This commit is contained in:
Jonathan Lemon 2000-12-05 16:21:00 +00:00
parent 38db6bf3e5
commit 76345c37d5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69621

View File

@ -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;
@ -121,6 +122,21 @@ tunattach(dummy)
cdevsw_add(&tun_cdevsw);
}
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;
}