Replace the last ether_input_mbuf() by if_input().

Index: net/if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.144
diff -u -p -r1.144 if_tun.c
--- net/if_tun.c        26 May 2015 11:36:26 -0000      1.144
+++ net/if_tun.c        28 May 2015 09:25:52 -0000
@@ -871,32 +871,34 @@ tunwrite(dev_t dev, struct uio *uio, int
        }
 
        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:

Reply via email to