From ceae12c823be5d5a5e7c53018f991d7206717bbb Mon Sep 17 00:00:00 2001 From: mpi Date: Sat, 3 Jun 2017 11:58:54 +0000 Subject: [PATCH] Add missing NET_LOCK(). Found by jmc@ --- sys/net/if_tun.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index b672107791a..80eaabff78e 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.176 2017/05/30 16:16:47 deraadt Exp $ */ +/* $OpenBSD: if_tun.c,v 1.177 2017/06/03 11:58:54 mpi Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -837,7 +837,7 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) struct ifnet *ifp; u_int32_t *th; struct mbuf *top, **mp, *m; - int error = 0, tlen; + int error = 0, tlen, s; size_t mlen; ifp = &tp->tun_if; @@ -930,6 +930,8 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) ifp->if_ipackets++; ifp->if_ibytes += top->m_pkthdr.len; + NET_LOCK(s); + switch (ntohl(*th)) { case AF_INET: ipv4_input(ifp, top); @@ -941,9 +943,12 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) #endif default: m_freem(top); - return (EAFNOSUPPORT); + error = EAFNOSUPPORT; + break; } + NET_UNLOCK(s); + return (error); } -- 2.20.1