From: mpi Date: Mon, 1 Jun 2015 07:48:04 +0000 (+0000) Subject: Convert tun(4) to if_input(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a6c54ecd21a4f418ff7778940de552296a1dab1d;p=openbsd Convert tun(4) to if_input(). Tested by Norman Golisz and , thanks! ok bluhm@ --- diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index c4ea429615c..4600a8cfa6c 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.144 2015/05/26 11:36:26 dlg Exp $ */ +/* $OpenBSD: if_tun.c,v 1.145 2015/06/01 07:48:04 mpi Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -871,32 +871,34 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag) } top->m_pkthdr.len = tlen; - top->m_pkthdr.rcvif = ifp; - -#if NBPFILTER > 0 - if (ifp->if_bpf) { - s = splnet(); - bpf_mtap(ifp->if_bpf, top, BPF_DIRECTION_IN); - splx(s); - } -#endif if (tp->tun_flags & TUN_LAYER2) { + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); + + ml_enqueue(&ml, top); s = splnet(); - ether_input_mbuf(ifp, top); + if_input(ifp, &ml); splx(s); - ifp->if_ipackets++; return (0); } +#if NBPFILTER > 0 + if (ifp->if_bpf) { + s = splnet(); + bpf_mtap(ifp->if_bpf, top, BPF_DIRECTION_IN); + splx(s); + } +#endif + th = mtod(top, u_int32_t *); /* strip the tunnel header */ top->m_data += sizeof(*th); top->m_len -= sizeof(*th); top->m_pkthdr.len -= sizeof(*th); top->m_pkthdr.ph_rtableid = ifp->if_rdomain; + top->m_pkthdr.rcvif = ifp; switch (ntohl(*th)) { case AF_INET: